4

I have pulled boot.img from my phone's CWM backup. How do I extract it? I tried split_bootimg.pl. But throws an error -

Android Magic not found in boot.img. Giving up.
  • What kind of phone is it from? – eldarerathis Jul 20 '12 at 14:26
  • @eldarerathis Sony Xperia P – Anirudh Jul 20 '12 at 14:31
  • Hm, okay. I've seen cases where some devices from smaller manufacturers use non-standard headers on their boot images, but I wouldn't expect that from Sony. I'd try the unpack-bootimg.pl script from here, maybe (instructions are covered in detail on this wiki page). Perhaps that one will be able to correctly unpack it. – eldarerathis Jul 20 '12 at 14:34
  • anirudh@Kat ~/Downloads/mkboot $ ./unpack-bootimg.pl /home/anirudh/Downloads/boot.img-tools/source_img/boot.img kernel written to /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-kernel.gz ramdisk written to /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk.cpio.gz gzip: ..//home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk.cpio.gz: No such file or directory cpio: premature end of archive extracted ramdisk contents to directory /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk/ – Anirudh Jul 20 '12 at 14:55
  • Related question: How to unpack and edit boot.img for ROM porting? – WhiteWinterWolf Aug 11 '16 at 15:38
1

After reading the comment, I spotted the error...

anirudh@Kat ~/Downloads/mkboot $ ./unpack-bootimg.pl /home/anirudh/Downloads/boot.img-tools/source_img/boot.img kernel written to /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-kernel.gz ramdisk written to /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk.cpio.gz gzip: ..//home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk.cpio.gz: No such file or directory cpio: premature end of archive extracted ramdisk contents to directory /home/anirudh/Downloads/boot.img-tools/source_img/boot.img-ramdisk/

For the boot.img-ramdisk.cpio.gz - this needs special handling... try this:

gzip -dc boot.img-ramdisk.cpio.gz | cpio -i

The way to do it is after unpacking the boot.img, create a directory called something like ramdisk, go into that directory and use gzip -dc ../boot.img-ramdisk.cpio.gz | cpio -i, the reason is, to organize the structure and files with minimum clutter.

gzip decompresses the ramdisk archive to stdout, pipe it into cpio with the -i switch to read from stdin and it will correctly extract the data.

To do the reverse, say after making a change here and there within the ramdisk directory:

mkbootfs ramdisk/ | gzip > my_new_ramdisk.gz
  • it gives me -dc: No such file or directory – Muhammed Refaat Sep 2 '14 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.