FORUMS
Remove All Ads from XDA

Unpacking, Editing, Packing ROMS [.IMG, .DAT] in Windows.

270 posts
Thanks Meter: 197
 
By HostZero, Senior Member on 2nd April 2016, 10:41 AM
Post Reply Email Thread
Unpacking, Editing, Packing ROMS GUIDE - Host Zero

First download the tools from the link below.



1. system.img
2. system.new.dat


1.Unpacking Repacking system.img

1. Paste your system.img in tools folder
2. Open cmd.exe
3. Type:
Code:
mkdir <your_folder_name>
ImgExtactor <raw_sparse.img> system -i

ex: ImgExtactor system.img system -i
4. Now open your folder you have created, you can find your <raw_image> has been extracted.
5. Now edit the files in system folder as your convenience.
6. Now open properties of folder you have created see the size of folder.
7. Now lets pack the image back, open the minimized command window.
Code:
make_ext4fs -s -l <size_of_your_folder+100>M -a system <name_of_packing_image>.img <your_folder_name>/

ex: make_ext4fs -s -l 512M -a system my_new_system.img system/
8. Done, enjoy!

2.Unpacking Repacking system.new.dat

1. Paste your system.new.dat, system.transfer.list and file_contexts in tools folder.
2. Open cmd.exe
3. Type:
Code:
sprs2ext system.transfer.list <name_of_system>.new.dat

ex: sprs2ext system.transfer.list system.new.dat
4. Now again type:
Code:
mkdir <your_folder_name>
ImgExtactor <raw_sparse.new.img> system -i

ex: ImgExtactor system.img system -i
5. Now open folder you have created and you will find the system.new.dat has been extracted.
6. Edit the extracted files.
7. Open properties of the extracted folder and check the size of folder
7. Now open minimized command window.
Code:
make_ext4fs -T 0 -S file_contexts -l <size_of_folder+100>M -a system <name_of_packing_image>.img <your_folder_name>/

ex: make_ext4fs -T 0 -S file_contexts -I 512M -a system my_new_system.img system/
8. Now again type:
Code:
rimg2sdat <your_raw_image>.img

ex: rimg2img my_new_system.img
9. Done! enjoy.

CLICK HERE TO DOWNLOAD TOOLS
The Following 8 Users Say Thank You to HostZero For This Useful Post: [ View ] Gift HostZero Ad-Free
 
 
6th April 2016, 12:03 PM |#2  
Senior Member
Flag Sana'a
Thanks Meter: 61
 
More
Thank you very much.
You refresh the xda University.

I hope the University becomes more active.

We really need more guides to master android OS.

Sent from my SM-N910P using Tapatalk
15th April 2016, 01:32 AM |#3  
Member
Thanks Meter: 5
 
More
I tried as rules mention on this thread. unpack was succeed. when I repack, here is the problem:
1. repack was succeed, but when I flash into my phone by spf tools, my phone was stuck at mi.com logo.
2. when I mount new system.img was created into DiskInternals Linux Reader, the file knowing as uknown file.

repack was succeed, but unable to use.
how to fix it?
24th April 2016, 09:18 PM |#4  
A useful guide! Thanks!

Sent from my Sony Xperia Z3 Compact using XDA Labs
6th May 2016, 07:24 PM |#5  
HostZero's Avatar
OP Senior Member
Flag Last Of Us (Pittsburgh)
Thanks Meter: 197
 
Donate to Me
More
Quote:
Originally Posted by kevin mitnick

I tried as rules mention on this thread. unpack was succeed. when I repack, here is the problem:
1. repack was succeed, but when I flash into my phone by spf tools, my phone was stuck at mi.com logo.
2. when I mount new system.img was created into DiskInternals Linux Reader, the file knowing as uknown file.

repack was succeed, but unable to use.
how to fix it?

hey a bit late but i may help you.

Causes for this:

1. May be your rom is odex.
2. May be you are using OTA Update or Patch instead of full rom.
3. Applying more size while building .img
4. make_ext4fs dosent support all kind of roms. it only supports roms based on ICS, JB, KK... but i dont know how google builds factory images then.

Anyways a alternative.

Flash a full stock or custom rom into your device (with root access and adb support)

connect your device
type in cmd:
adb shell
su
(grant permissions on your device)
ls -al /dev/block/platform/*/by-name
now you will get your PMT table (Partition Management Table.)
ex: system ---> /dev/block/mmcblk07
and other partition information also.
now make system.img using adb.
dd if=/partitionnumber of=/sdcard/system.img
ex: dd if=/dev/block/mmcblk07

now you can find fastboot flashable system.img in your sdcard.

do rest with other partitions also. (boot partition manadatory).

enjoy.
6th May 2016, 07:25 PM |#6  
HostZero's Avatar
OP Senior Member
Flag Last Of Us (Pittsburgh)
Thanks Meter: 197
 
Donate to Me
More
Quote:
Originally Posted by Ticklefish

A useful guide! Thanks!

Sent from my Sony Xperia Z3 Compact using XDA Labs

Thankyou sir for encouraging.
6th May 2016, 07:26 PM |#7  
HostZero's Avatar
OP Senior Member
Flag Last Of Us (Pittsburgh)
Thanks Meter: 197
 
Donate to Me
More
Quote:
Originally Posted by Ticklefish

A useful guide! Thanks!

Sent from my Sony Xperia Z3 Compact using XDA Labs

Your Welcome sir.
9th May 2016, 03:35 AM |#8  
Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by HostZero

hey a bit late but i may help you.

Causes for this:

1. May be your rom is odex.
2. May be you are using OTA Update or Patch instead of full rom.
3. Applying more size while building .img
4. make_ext4fs dosent support all kind of roms. it only supports roms based on ICS, JB, KK... but i dont know how google builds factory images then.

Anyways a alternative.

Flash a full stock or custom rom into your device (with root access and adb support)

connect your device
type in cmd:
adb shell
su
(grant permissions on your device)
ls -al /dev/block/platform/*/by-name
now you will get your PMT table (Partition Management Table.)
ex: system ---> /dev/block/mmcblk07
and other partition information also.
now make system.img using adb.
dd if=/partitionnumber of=/sdcard/system.img
ex: dd if=/dev/block/mmcblk07

now you can find fastboot flashable system.img in your sdcard.

do rest with other partitions also. (boot partition manadatory).

enjoy.

thanks for respon @HostZero so much lessons and knowledge about this.
I'll try..report asap
9th May 2016, 05:37 AM |#9  
HostZero's Avatar
OP Senior Member
Flag Last Of Us (Pittsburgh)
Thanks Meter: 197
 
Donate to Me
More
Quote:
Originally Posted by kevin mitnick

thanks for respon @HostZero so much lessons and knowledge about this.
I'll try..report asap

This method is know as dumping method thanks to dd and su in android devices.
10th May 2016, 11:23 AM |#10  
hamed24's Avatar
Senior Member
Thanks Meter: 21
 
More
Cmd.exe not work on windows 7 32bit

😭

sent from Xperia™ SP | Android 6.0.1
10th May 2016, 04:29 PM |#11  
Recognized Developer
Thanks Meter: 1,845
 
Donate to Me
More
It seems to me that the permissions would be lost when they are dumped from system.img via this method. Are you seeing the selinux contexts preserved?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes