FORUMS
Remove All Ads from XDA

[Guide] How to create EXT4 images.

246 posts
Thanks Meter: 75
 
Post Reply Email Thread
Since most of the high-end devices are using now EXT4 partitions i decided to make a guide.
I am doing this because this is the easiest way to create an EXT4 image.
This is not my guide I am just adapting and make it clear to everybody; someone showed me how to do this (I will mention him at the end of the guide).



Let`s assume that you dumped the system.img from your own device and you want to add something to it.
We will create a new system.img and we will name it system_new.img, the size will be 240 Mb.

Step 1
Linux Machine (I used Ubuntu)
We prepare the the directories and copy the system.img in the folder in which we will work.
mkdir system (here we will mount the old system.img
mkdir system_new (here we will mount the system_new.img)


Step 2 – Creation of the actual EXT4.img
dd if=/dev/zero of=system_new.img bs=4k count=60000
Translation of the terms,
bs =blocksize, 4k= the size of the block`s which in this case are 4kb
count=60000, the number of block`s, in our case will result an image of 240 Mb.
The blocksize can be 1k/2k/4k/16k
To get the exact size of the image that you create use simple maths.
60000 * 4 = 240000

Step 3 Formating the system_new.img with EXT4
mkfs.ext4 system_new.img
It will be a question where you will select yes (Y)
We override the file system check (If you don`t do this, the image will not work)
tune2fs -c0 -i0 system_new.img

Step 4 We mount the directories that we previous created.
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/

Step 5 We copy the content from the old system.img in the system_new.img
cp -v -r -p system/* system_new/
We sync the files
sync

Step 6 Unmounting the partitons.
umount system_new/
umount system/

Step 7 Enjoy your new ext4 system.img

Tips:
If you are using Ubuntu just type
sudo su
And you will be root and no more sudo at each command.
You can add new files in the new created system.img but you need to set the permissions and ownership properply, otherwise it will not work.

Credits: arctablet.com administrator.
The Following 11 Users Say Thank You to globula_neagra For This Useful Post: [ View ] Gift globula_neagra Ad-Free
 
 
7th March 2013, 08:21 AM |#2  
Senior Member
Flag Modiin
Thanks Meter: 1,052
 
Donate to Me
More
work perfect!
I managed to create a new system img for huawei phone.
12th November 2014, 06:43 AM |#3  
Junior Member
Flag Delhi
Thanks Meter: 0
 
More
Unhappy Errors in Step 3 and 4: Unable to proceed
Hi There,
I am getting errors in step 3 and 4.

Step 3 Formating the system_new.img with EXT4
mkfs.ext4 system_new.img
It will be a question where you will select yes (Y) -- after this below error comes

Device size reported to be zero. Invalid partition specified, or partition table wasn't reread after running fdisk, due to a modified partition being busy and in use. You may need to reboot to re-read your partition table.

We override the file system check (If you don`t do this, the image will not work)
tune2fs -c0 -i0 system_new.img -- after this below error comes

Attempt to read block from filesystm resulted in short read while trying to open system.img

Step 4 We mount the directories that we previous created.
mount -o loop system_new.img system_new/ -- after this below error comes

unknown filesystem type 'ext4'

Could you please help.
2nd August 2015, 10:20 AM |#4  
Senior Member
Thanks Meter: 94
 
More
i whant to create and system.img.ext4 for my android ! ! But i saw that image which is created is just system.img ! I`m using ubuntu and i whant to know what is need it to create that system.img.ext4 ! I don`t see that img to be ext4 file ! Thanks
24th February 2016, 08:12 PM |#5  
w1nst0n sm1th's Avatar
Member
Thanks Meter: 13
 
More
Quote:
Originally Posted by jabarel

i whant to create and system.img.ext4 for my android ! ! But i saw that image which is created is just system.img ! I`m using ubuntu and i whant to know what is need it to create that system.img.ext4 ! I don`t see that img to be ext4 file ! Thanks

I'm not sure but it's probably just a matter of file extenstion.


By the way, great tuto. May be someting to add :
Android ext4 don't seem to be the exact standart of linux ext4 file systems.

To make it fully compatible and usable with fastboot, the use of "ext2simg" can be useful.

So it will be something like this :

ext2simg fs2convert.img fsconverted.img

ext2simg can be found in android-tools in debian repository.
20th March 2016, 05:44 AM |#6  
manuhackzzz's Avatar
Senior Member
Flag Jaipur
Thanks Meter: 40
 
More
I am porting a rom ,i extracted "system.new.dat" into "sytem" folder , applied changes according to this guide to port a ROM -->> http://forum.xda-developers.com/show...8#post65933478
can you tell me how to reconstruct the "system.new.dat" from "sytem" folder ?
26th March 2017, 03:25 AM |#7  
Member
Flag Mysore
Thanks Meter: 20
 
More
is mkfs.ext4 applet available to arm devices..??
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