Image convert

unpack android boot image

1
2
3
4
5
6
git clone https://github.com/osm0sis/mkbootimg.git
mkdir kernel && mkbootimg/unpackbootimg -i boot.img -o kernel
cd kernel
dd bs=64 skip=1 if=boot.img-ramdisk.gz of=a.gz
mkdir ramdisk && cd ramdisk
gunzip -c ../a.gz | cpio -i

raw to ext4

1
2
git clone https://github.com/xpirt/sdat2img.git
python sdat2img/sdat2img.py system.transfer.list system.new.dat system.new.ext4

Ubuntu x64 - Guide

Step 1 - Decompressing = DAT (sparse data) -> EXT4 raw image)

We’re now using sdat2img binary, the usage is very simple (make sure you have python 3.x installed):

1
./sdat2img.py <transfer_list> <system_new_file> <system_ext4>
  • <transfer_list> = input, system.transfer.list from rom zip
  • <system_new_file> = input, system.new.dat from rom zip
  • <system_ext4> = output ext4 raw image file

and a quick example:

1
./sdat2img.py system.transfer.list system.new.dat system.img

by running this command you will get as output the file my_new_system.img which is the raw ext4 image.

Step 2 - Decompress EXT4 (raw image) -> OUTPUT folder -> Compress EXT4 (raw image)

Now we need to mount or ext4 raw image into an output folder so we can see apks/jars etc.
To do this we need to type this command:
sudo mount -t ext4 -o loop system.img output/
As you can see there is a new folder called output which we can edit/modify/delete your files (not able to? see here)

Now we need to compress it back to a raw ext4 image, to do this we need the make_ext4fs binary. Make sure you have thefile_contexts file (taken from the Rom zip) inside the make_ext4fs path. Then type this (got issues? see here)

1
./make_ext4fs -T 0 -S file_contexts -l 1073741824 -a system system_new.img output/

You will get the new raw ext4 image called ‘system_new.img’ ready for the next step.

Step 3 - Converting = EXT4 (raw image) -> DAT (sparse data)

Now we need the rimg2sdat binary, the usage is very simple:

1
./rimg2sdat <system_img>
  • <system_img> = name of input ext4 raw image file

and a quick example:

1
./rimg2sdat my_new_system.img

As you can see the output is composed by system.transfer.list, (system.patch.dat) & system.new.dat, ready to be replaced inside your Rom zip.