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

Search This thread

HostZero

Senior Member
Jun 28, 2015
298
302
Last Of Us (Pittsburgh)
Unpacking, Editing, Packing ROMS GUIDE - Host Zero

First download the tools from the link below.

new%2Bprof.png


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
 
Last edited:

anees02

Senior Member
Feb 9, 2009
679
98
Sana'a
Xiaomi 12T Pro
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
 

kevin mitnick

Senior Member
Oct 28, 2011
323
49
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?
 
Last edited:

HostZero

Senior Member
Jun 28, 2015
298
302
Last Of Us (Pittsburgh)
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.
 

kevin mitnick

Senior Member
Oct 28, 2011
323
49
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
 

hamed24

Senior Member
Sep 25, 2014
128
37
Cmd.exe not work on windows 7 32bit

?

sent from Xperia™ SP | Android 6.0.1
 

hamed24

Senior Member
Sep 25, 2014
128
37
No problem. Open your tools folder in full screen. now below empty white space click (Shift + RightClick) then select Open Command Window Here.

Done!
Thanks for your help,that's work
Can you take screenshot from your cmd and typed codes, I'm beginner and confused some codes ?

sent from Xperia™ SP | Android 6.0.1
 

HostZero

Senior Member
Jun 28, 2015
298
302
Last Of Us (Pittsburgh)
Thanks for your help,that's work
Can you take screenshot from your cmd and typed codes, I'm beginner and confused some codes

sent from Xperia™ SP | Android 6.0.1

Sorry bro I have recently shifted to Ubuntu14.04 for learning building. Read guide properly you will understand more. I have even provided examples as well as commands. and commands depends in each system folder.
 

daywalker386

Member
Oct 26, 2012
46
22
Freiburg
OnePlus 7 Pro
Cmd.exe not work on windows 7 32bit

?

sent from Xperia™ SP | Android 6.0.1
Hi hamed24
Start-->run--> cmd.exe didn´t work? but using the right Mousebutton is okay?
Seems that Windows has lost the C:\Windows\system32 entry in the PATH Variable... easy to fix...
1. Press "Windows-Sign" Key and Break at the same time (it´s the same as rightclick on the Computer-Icon on the Desktop), click on Advanced System Settings.
2. Inside the new Window, click on Environment Variables, a new window opens. Now the lower part is the important one... look for PATH and doubleclick it.
3. At the end of the line, check if there is a ";" (without quotes). That seperates the different entries.... if there´s one there ... ok, place cursor at the end and enter C:\WINDOWS\SYSTEM32;
4. Hit ENTER, close all Windows, log off and on again.... and try again, should work now. If not, go to Start-->Run--> and type C:\WINDOWS\SYSTEM32\CMD.EXE and there you are :)

regards...
daywalker386
 
  • Like
Reactions: hamed24

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    Unpacking, Editing, Packing ROMS GUIDE - Host Zero

    First download the tools from the link below.

    new%2Bprof.png


    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
    2
    Cmd.exe not work on windows 7 32bit



    sent from Xperia™ SP | Android 6.0.1



    No problem. Open your tools folder in full screen. now below empty white space click (Shift + RightClick) then select Open Command Window Here.

    Done!
    1
    A useful guide! Thanks!

    Sent from my Sony Xperia Z3 Compact using XDA Labs
    1
    Cmd.exe not work on windows 7 32bit

    ?

    sent from Xperia™ SP | Android 6.0.1
    Hi hamed24
    Start-->run--> cmd.exe didn´t work? but using the right Mousebutton is okay?
    Seems that Windows has lost the C:\Windows\system32 entry in the PATH Variable... easy to fix...
    1. Press "Windows-Sign" Key and Break at the same time (it´s the same as rightclick on the Computer-Icon on the Desktop), click on Advanced System Settings.
    2. Inside the new Window, click on Environment Variables, a new window opens. Now the lower part is the important one... look for PATH and doubleclick it.
    3. At the end of the line, check if there is a ";" (without quotes). That seperates the different entries.... if there´s one there ... ok, place cursor at the end and enter C:\WINDOWS\SYSTEM32;
    4. Hit ENTER, close all Windows, log off and on again.... and try again, should work now. If not, go to Start-->Run--> and type C:\WINDOWS\SYSTEM32\CMD.EXE and there you are :)

    regards...
    daywalker386