Thread: PRS-T1 Altering Root FS
View Single Post
Old 09-03-2012, 06:26 PM   #5
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
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.

Last edited by e-ink; 09-03-2012 at 11:04 PM. Reason: accidentally clicked submit while still creating this post
e-ink is offline   Reply With Quote