I have found a simple solution: http://andwise.net/?p=403
(with slight adjustments for better readability)
This is for all who want to unpack and modify the original system.img that you can flash using recovery. system.img (which you get from the google factory images for example) represents a sparse ext4 loop mounted file system. It is mounted into /system of your device. Note that this tutorial is for ext4 file system. You may have system image which is yaffs2, for example.
The way it is mounted on Galaxy Nexus:
/dev/block/platform/omap/omap_hsmmc.0/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0
- Linux box or virtual machine
- simg2img and make_ext4fs binaries, which can be downloaded from the linux package android-tools-fsutils
Place your system.img and the 2 binaries in one directory, and make sure the binaries have exec permission.
Part 1 – mount the file-system
mkdir sys ./simg2img system.img sys.raw sudo mount -t ext4 -o loop sys.raw sys/
Then you have your system partition mounted in ‘sys/’ and you can modify whatever you want in ‘sys/’. For example de-odex apks and framework jars.
Part 2 – create a new flashable system image
sudo ./make_ext4fs -s -l 512M -a system new.img sys/ sudo umount sys rm -fr sys
Now you can simply type:
fastboot flash system new.img
In Android file system, "system.img" and "userdata.img" are VMS Alpha executable. "system.img" and "userdata.img" have the contents of /system and /data directory on root file system. They are mapped on NAND devices with yaffs2 file system. Now, yaffs2 image file can not be mounted on linux PC. If you can, maybe you got some rom that not packed in yaffs2 file system. You can check those rom file by execute the command:
If it show "VMS Alpha executable" then you can use "unyaffs" to extract it.
I have found that Furius ISO mount works best for me. I am using a Debian based distro Knoppix. I use this to Open
system.img files all the time.
Furius ISO mount:
"When I want to mount userdata.img by mount -o loop userdata.img /mnt/userdata (the same as system.img), it tells me mount: you must specify the filesystem type so I try the mount -t ext2 -o loop userdata.img /mnt/userdata, it said mount: wrong fs type, bad option, bad superblock on...
So, how to get the file from the inside of userdata.img?"
.img files you have to select loop and load the
.img Select loop
Next you select mount Select mount
Furius ISO mount handles all the other options loading the
.img file to your /home/dir.