How To : Create System.IMG from System Folder - Repack System.IMG

itxtutor

Editor in Chief
Staff member
May 15, 2015
60,104
471
113
#1
Hey guys,


I´ve seen that many people have problems because mtk droid tools created a system folder and not an image for the backup.


PLEASE ONLY DO THIS AFTER YOU TRIED :


1) Open mtk droid tools


2) Prepare blocks for flashtool in mtk droid tools


3) chose files.md5


4) Check if you have the image in "files to flashtool"


So today i got some time and wrote a tutorial on how to repack that folder to a system.img.


that only works for EXT4 FILESYSTEM based devices. For Yaffs i will do another tutorial.


What you need:


1) A linux pc or VM ware + Any linux distribution


2) simg2img and make_ext4fs binaries which can be downloaded from here :


http://web.djodjo.org/?a=download:android:tools:x86_linux:ext4tools


Now to start, log in on your Linux PC or start VM.


Now create a folder somewhere and copy in :


1) Simg2Img


2) Make_ext4


3) A random system.img or the system.img you want to mod! ( needrom or whatever,)


When you have done that, open a new terminal session.


Type

cd /"directory"  
to change to your directoy which contains the files.


Now we need to run those 3 commands :

1. mkdir sys                                              (creates a new folder sys in your directory)


2. ./simg2img system.img sys.raw              (unpacks system.img)


3. sudo mount -t ext4 -o loop sys.raw sys/   (mounts it)
It should look like this :








Then your system.img is mounted in sys. and you can mod it.  


Now just delete everything from that system.img and copy in the files from your backup folder. Also verify that everything is in there !





Now its time to repack to system.img !

1. sudo ./make_ext4fs -s -l 512M -a system new.img sys/


2. sudo umount sys


3. rm -fr sys
At the end it should look like this :





Now you can flash your new  "new.img" to your smartphone with sp-flashtools



I hope this solved your issues with the backup !


Cheers
 
Last edited by a moderator:
Jul 31, 2014
40
0
6
#2
Yay! Thank you so much for your help! I managed to revive my wife's phone!
 



Is there some way to make the ".img" of nvram? (my backup didn't made it...) can i make it the same way?


Thank you so much again!
 
Jul 31, 2014
40
0
6
#3
Hey Itxtutor!



I have some doubts...

  • have i just do this repack process by doing just: "sudo ./make_ext4fs -s -l 512M -a system new.img sys/" ?



  • will it be bugged as i told you in my topic? because my backup had only system folder and nvram folder and doesn't have the sys.raw file.



  • "sudo mount -t ext4 -o loop sys.raw sys/" was not needed to do?



  • And what about the " rm -fr sys "? what is this one for?



Thanks in advance. If you want to delete my question and answer in my note 3 post, don't mind to do it.
 

itxtutor

Editor in Chief
Staff member
May 15, 2015
60,104
471
113
#4
I replied in the other thread.


pepe,


did you use a donor system.img or did you just put your system folder in the folder ?


2. ./simg2img system.img sys.raw (unpacks system.img)


extracts the SYSTEM.IMAGE !!! (not folder) to a sys.raw file !
 
Jul 31, 2014
40
0
6
#5
Ok, Itxtutor. I just used the system folder in the folder. I got that it's for extract the " SYSTEM.IMAGE !!! " haha.


I'm talking about: "sudo mount -t ext4 -o loop sys.raw sys/ (mounts it)"


I can't mount it in because it isn't a sys.raw, it's just a folder.


I've read somewhere that my problem is because the "sys" folder is just in "read" mode and i need to change it to read-write before repack it into a .img file. Can you tell me how to do it?
 
Oct 24, 2014
6
0
1
#9
hi dear friends


i have problem with unpack system.img file for nokia X


when i type /simg2img system.img sys.raw  ===> Terminal say Error :bash : ./simg2img  : No Such File Or Directory :screaming:


reason ?


what should i do ?i use vm virtual box
 

itxtutor

Editor in Chief
Staff member
May 15, 2015
60,104
471
113
#18
check file permission http://stackoverflow.com/questions/18960689/ubuntu-says-bash-program-permission-denied


and run as SU
 

teemo

New Member
Feb 14, 2015
2
0
1
26
#19
thanks you for your answer my problem solved ... but i have another problem ... how to unpack and repack system.img for android 4.3 , 4.4.2 and 4.4.4 since simg2img can not unpack them and says : invalid parser header