Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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.
share|improve this question
    
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
add comment

2 Answers 2

up vote 1 down vote accepted

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
share|improve this answer
    
Thank you @t0mm13b. –  Anirudh Aug 1 '12 at 7:49
add comment

android Magic not found in boot.img. Giving up.

I got similar error, when I tried with the ROM.zip.

Then I extracted the zip file "unzip ROM.zip". Which gave the following structure. Then I extracted the boot.img.

drwxr-xr-x 3 vramaraj sw-team 4096 Oct 9 2011 data/

-rw-r--r-- 1 vramaraj sw-team 70 May 16 2012 installbusybox

drwxr-xr-x 4 vramaraj sw-team 4096 Oct 6 19:03 sdcard/

drwxr-xr-x 16 vramaraj sw-team 4096 Nov 28 22:14 system/

-rw-r--r-- 1 vramaraj sw-team 4073472 Dec 2 22:27 boot.img

-rw-r--r-- 1 vramaraj sw-team 302938 Dec 3 21:14 logo.bin

-rw-r--r-- 1 vramaraj sw-team 236601691 Jan 31 22:18 ROM.zip

-rwxr-xr-x 1 vramaraj sw-team 6773 Jan 31 22:18 split_bootimg.pl*

drwxr-xr-x 3 vramaraj sw-team 4096 Jan 31 22:19 META-INF/

-rw-r--r-- 1 vramaraj sw-team 3477896 Jan 31 22:21 boot.img-kernel

-rw-r--r-- 1 vramaraj sw-team 591679 Jan 31 22:21 boot.img-ramdisk.gz

drwxr-xr-x 2 vramaraj sw-team 4096 Jan 31 22:21 ramdisk/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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