Skip to content


Subversion checkout URL

You can clone with
Download ZIP
The complement to Android's mkbootimg
C Shell
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
unbootimg.c dont fail in mkdir



When working on Android, I found it useful to be able to unpack a boot image, replace a few files and repack it. unbootimg is the perfect complement to the mkbootimg tool that is used to create boot images.

unbootimg takes a boot image and produces all that is necessary in order to create a new image using mkbootimg. In particular it extracts the kernel command line and the addresses of the image parts, and creates a command line for mkbootimg to regenerate the image as close to the original one. It even verifies the SHA1 checks!

unpack and repack and are trivial shell wrappers for unbootimg that also take care of the ramdisk packaging: cpio and gzip. They are designed to complement, so that this would simply recreate boot.img without changes: boot.img boot.img


If you already have the AOSP repo and managed to build mkbootimg, adding unbootimg is easy.

  • Download the unbootimg source
  • Unpack it to your mydroid/repo/system/core/mkbootimg. Note: it overwrites to include unbootimg.
  • Build it:

    cd mydroid/repo
    . build/
    make mkbootimg unbootimg
    # sadly that can't install and so we need:
    mmm system/core/mkbootimg
  • Put mydroid/repo/out/host/linux-x86/bin in your path. Easiest way to do this is:

    setpaths  # this is defined by Android build system: . build/

unbootimg depends (like mkbootimg) on libmincrypt for computing the SHA1, but this can easily be disabled in the source code.


# on the phone: copy the boot or recovery image, for example
dd if=/dev/mtd/mtd3 of=/sdcard/recovery-backup.img
# on the host: pull the backup
adb pull /sdcard/recovery-backup.img .
# unpack it recovery-backup.img
# edit as you wish:
# cmdline: recovery-backup.img-mk
# kernel:  recovery-backup.img-kernel
# ramdisk: recovery-backup.img-ramdisk/
# repack it recovery-backup.img
# send to phone
adb push recovery-backup.img /sdcard
# flash it using flash_image
Something went wrong with that request. Please try again.