How to extract boot.img?

boot.img is a small(ish) file that contain two main parts.

          * kernel(important for android)
          * ramdisk( a core set of instruction & binaries)

Unpack boot.img:

It contains the following steps:

  1. Download the tool using wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android-serialport-api/android_bootimg_tools.tar.gz

  2. Extract the file using tar xvzf android_bootimg_tools.tar.gz.

    It contains two binaries:

           * unpackbootimg
           * mkbootimg
    

3.Then execute ./unpackbootimg -i <filename.img> -o <output_path>

It will contain,

           * boot.img-zImage     ----> kernel
           * boot.img-ramdisk.gz ----> ramdisk

We can extract ramdisk also, using the following command

gunzip -c boot.img-ramdisk.gz | cpio -i

After changing the files, we can again pack those files as boot.img using mkbootimg

Have fun!


boot.img is not a compressed filesystem image like system.img. It is read by the bootloader, and contains little more than a kernel image and a ramdisk image.

Some binary distribution ship the kernel and ramdisk images separately. In that case you don't need to do anything with boot.img, just regenerate a new one with mkbootimg.

If you need to extract information from a boot.img, try split_bootimg (by William Enck, via the Android wiki).


I use opensuse. I have installed abootimg. If you want to extract (boot|recovery).img run such:

abootimg -x (boot|recovery).img

Then you get next files: bootimg.cgf, zImage and initrd.img If you want to pack image you run such

abootimg --create (boot|recovery).img -f bootimg.cfg -k zImage -r initrd.img

Then you'll get (boot|recovery).img

Enjoy