[Guide] How to create EXT4 images.

Search This thread

globula_neagra

Senior Member
Jun 28, 2009
261
79
Birmingham
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 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 is 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 properly, otherwise it will not work.

Credits: arctablet.com administrator.
 
Last edited:

aky_style

Member
Sep 24, 2011
19
0
Delhi
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.
 

jabarel

Senior Member
Sep 15, 2014
753
114
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
 

w1nst0n sm1th

Senior Member
Feb 3, 2016
86
20
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.
 

Xumxum

New member
Apr 20, 2018
1
0
you can do it faster...

Great if you create a new image, but to edit no need to create all these steps ...
Just copy the system.img to system_new.img and mount that one and edit..
 

Frank2406

Member
Jan 22, 2019
8
0
Blommenholm
There's no clear instruction!

Hours of researching many places and no good instruction about how to create or edit an EXT4 with or without Linux!
I know this is an old post but I just wanted to try, might get a reply!
 

globula_neagra

Senior Member
Jun 28, 2009
261
79
Birmingham
Hours of researching many places and no good instruction about how to create or edit an EXT4 with or without Linux!
I know this is an old post but I just wanted to try, might get a reply!



what is not clear?
this has been tested by me and it works.

there are more refined ways in doing it, it just depends on what you need to to with the ext4 image.
 

Frank2406

Member
Jan 22, 2019
8
0
Blommenholm
what is not clear?
this has been tested by me and it works.

there are more refined ways in doing it, it just depends on what you need to to with the ext4 image.

Step 1: "We prepare the directories" you said. What directories?
"mkdir system"
"mkdir system_new" which, what or where are they?

Step 2: The whole step 2 for a newbie in Linux like me is bla bla bla except the title "Creation of the actual EXT4.img"!
And the rest of your guide is as the same as step 2 which I mentioned.

And if this guide is for Ubuntu experts then maybe in the beginning you could mention so people don't get their hopes up dear globula_neagra!!

Long story short, I just wanted to try a custom Rom on my Zenwatch 1, but I've forgot to make backup, so the official Rom was gone. Asus itself didn't help to get a copy of the official one, so I tried Anthias custom Rom instead, but that made the watch even worse.
Then I started to research how to fix it, so I found this article.
 

globula_neagra

Senior Member
Jun 28, 2009
261
79
Birmingham
It s not a step by step guide on how to use ubuntu.
I assume that wheen you want to learn something you do use google too. For this instance i would google in this way "what does mkdir command in ubuntu"
After i understood the purpose of the command and how to use it i would try to apply it using the guide and after that you will see that things will start to make sense.

My guide was written with the idea that if you use android you have an idea of linux too and in this case ubuntu.

The command line in linux is somewhat similar to the one in windows commander there are some extra things that you need to learn but those can t be put in a guide like this.

In regards to your watch. My advice is to find another one and take a system dump from that one and flash it to yours if you have an unlocked bootloader.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 11
    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 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 is 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 properly, otherwise it will not work.

    Credits: arctablet.com administrator.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone