Solved:
The image is actually a special
uboot ramdisk image. This format adds a header containing a CRC32 checksum to the compressed image.
In the above example, the new image is used in combination with the old headers. Not good
This is better (we need
mkimage):
Warning: Don't apply any of those commands if you don't understand what they are doing. You can easily make you're device unbootable. The commands are partly transcribed without further testing. I can't guarantee that they will work as expected
Code:
# create & change directory to where we extract the files later on
mkdir ~/rootfs && cd ~/rootfs
# for safety reasons back up the whole root fs area (including uboot headers)
dd if=/dev/mmcblk2 of=../rootfs.img bs=1 skip=5242880 count=1048576
# copy the compressed root fs image (without uboot headers)
dd if=/dev/mmcblk2 of=../rootfs.img.gz bs=1 skip=5242944 count=1048512
# extract root fs
gunzip -c ../rootfs.img.gz | cpio -i
Happy init.rc editing
Code:
# re-create compressed image
find . | cpio -o -H newc | gzip > ../newrootfs.img.gz
# convert into special uboot format (adding headers to image)
mkimage -A arm -O linux -C gzip -T ramdisk -n "Normal Rootfs" -a 0x500040 -e 0x500040 -d ../newrootfs.img.gz ../newrootfs.img
# apply new image (make sure size of newrootfs.img ≤ rootfs.img)
# you also might wanna consider zeroing out the rootfs area before applying the new image to make sure there are no leftovers
dd if=../newrootfs.img of=/dev/mmcblk2 bs=1 seek=5242880
P.S. It smells like the kernel is of the same uboot format and could be changed the same way.