Search code examples
androidandroid-source

How to mount AOSP .img files?


I generate *.img by building AOSP.

Like ramdisk.img,boot.img etc.

I want to mount this file. I'm using Ubuntu.


Solution

  • You cannot mount boot.img file. However you can unpack it's ramdisk.

    The boot.img file contains:

    • ramdisk
    • zImage (kernel binary)
    • dt.img (device tree)

    There is an excellent open source project: mkbootimg_tools at GitHub. You can use it to split the boot.img file and unpack the ramdisk.

    Unpack boot.img:

    mkbootimg_tools/mkboot boot.img boot_unpacked
    

    To unpack system.img you first need to understand what kind of partition is it: run: file system.img

    If you get 'Android sparse image', then you have a sparse image, meaning you need to un-sparse it before mounting: simg2img system.img system_raw.img

    Then you can mount system_raw.img simply by running: sudo mount system_raw.img /mnt/android_sys