2012年11月3日星期六

A script to modify Samsung Galaxy S3's rootfs (including init scrpit)



Granted you will need to modified it according to your own environment, and install appropriate software (mkbootimg, etc.)

After running this script, you could use clockworkmode (which should be in your recovery image if your phone is rooted, so you might not want to reflash recovery.img...) to flash modifed image (here only boot.img is modifed) to your phone.

In this script, new boot.img is located in /emmc/clockwork/mod in recovery mode.

You only need to restore boot.img to save time.

Reference:
how to unpack/repack boot images (including ramdisk):
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images
how to calucate md5:
http://www.mydigitallife.info/how-to-calculate-and-generate-md5-hash-value-in-linux-and-unix-with-md5sum/
Linux cpio facility:
man cpio
http://www.gnu.org/software/cpio/

Restore.sh:
cd modified3-2012-11-01.17.05.34/
mkdir tmp
cd tmp/
unpackbootimg -i ../boot.img
mkdir ramdisk
cd ramdisk
gunzip -c ../boot.img-ramdisk.gz |cpio -i
/bin/cp /scratch/suli/android/samsung/config/init.rc init.rc
/bin/cp /scratch/suli/android/samsung/programs/slowdevice/null_bd/null_bd.ko lib/modules/null_bd.ko
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
cd ..
rm -rf ramdisk
/bin/mv newramdisk.cpio.gz boot.img-ramdisk.gz
mkbootimg  --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz --pagesize 2048 --base 10000000 -o ../newboot.img
cd ..
rm -rf tmp
/bin/mv newboot.img boot.img
rm -f nandroid.md5
md5sum boot.img  cache.ext4.tar  data.ext4.tar   recovery.img  system.ext4.tar > nandroid.md5
adb push boot.img /sdcard/clockworkmod/backup/modified-2012-11-01.17.05.34/boot.img
adb push nandroid.md5 /sdcard/clockworkmod/backup/modified-2012-11-01.17.05.34/nandroid.md5

没有评论:

发表评论