Extract boot.img from an android device, unpack/repack it, and write it back to the android device.
March
10th,
2014
I did this on my rooted, boot-unlocked Nexus 7 II running Android 4.4.2 under Windows.
This tutorial pointed me in the right direction.
###boot.img Retrieve Instructions
I use adb tools to retrieve the desired boot-from-android-device.img
, after that, I use Root Explorer
to copy the file, so that
we can copy the file to computer through MTP:
;use the following commands to found the boot partition,note:msm_sdcc.1 is different on different android device
adb shell
ls -l /dev/block/platform/
;now we know the device platform is msm_sdcc.1
ls -l /dev/block/platform/msm_sdcc.1/by-name
; now we know the boot partition is cat mmcblk0p14 by [boot -> /dev/block/mmcblk0p14]
;use the following command to retrieve the boot.img
su
cat /dev/block/mmcblk0p14 > /sdcard/boot-from-android-device.img
chmod 0666 /sdcard/boot-from-android-device.img
###Repack Instructions I use Android Image Kitchen to unpack the boot.img and repack it to boot-from-android-device-repacked.img.
1) Unzip
2) Either use the command-line "unpackimg <image-filename.img>", or simply drag-and-drop the image. This will split the image and unpack the ramdisk to a subdirectory.
3) Alter the ramdisk as you like.
4) The repackimg batch script requires no input and simply recombines the previously split zImage with the newly packed modified ramdisk using all the original image information (which was also split and saved).
5) The cleanup batch script resets the folder to its initial state, removing the split_img+ramdisk directories and any new packed ramdisk or image files.
###Write the boot.img back to the Android device. I use fastboot tool to do the job.
adb reboot-bootloader
;[wait for bootloader to come up]
fastboot flash boot boot-from-android-device-repacked.img
fastboot reboot