AOSP img files tips and tricks

Example commands for working with AOSP img files on a Mac

AOSP builds are generally a zip containing a number of .img files. At least this is the case for the builds you download from https://developers.google.com/android/images.

These images aren't a fixed format - they may contain any number of types of data. To see what you have, try running:

% file boot.img
boot.img: Android bootimg, kernel (0x800), ramdisk ...

Another example:

% file vendor.img
vendor.img: Android sparse image, version: 1.0, ...

Another example (file doesn't understand the vbmeta format)

% file vbmeta.img
vbmeta.img: data

imjtool is more sophisticated. It can recognize the vbmeta.img format (you'll need to download the binary first):

% imjtool vbmeta.img
vbmeta.img: Android Verified Boot image, version 1.0, ...

For some image types (e.g. boot/sparse) it can even extract the contents:

% imjtool vendor.img extract all
Sparse image v1.0 detected (in container at offset 0x0)
181465 blocks of 4096 bytes compressed into 15 chunks (1% compressed)
0 - Extracted image is in extracted/image.img
% ls extracted
image.img
% imjtool extracted/image.img
Linux Ext4 filesystem image, Volume name: vendor

If you encounter an image that's an ext file system, you can use e2tools to access its content without mounting it (It's super annoying to mount EXT filesystems on Mac because it requires FUSE, which requires disabling some system protections).

% brew install e2tools
...
% e2ls extracted/image.img:/
app             bin             build.prop      default.prop    dsp
...
% e2cp extracted/image.img:/build.prop build.prop

Some of the devices I work with don't have adb enabled, so I can't just adb shell into a running system to examine what's going on. Other times I want to examine the configuration for a build that I don't have currently installed. Maybe I don't even have a device that I can install that build on. It's nice to be able to examine the images directly. For example, on a running system with adb enabled I might use adb shell zcat /proc/config.gz to see kernel configs. I can access those same configs working directly from images:

% imjtool boot.img extract all
boot.img: Android Boot image v2 for OS ver ...
...
% git clone https://github.com/torvalds/linux.git
...
% LC_ALL=C linux/scripts/extract-ikconfig extracted/kernel.decompressed
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 4.14.170 Kernel Configuration
#
CONFIG_ARM64=y
CONFIG_64BIT=y
...

Note that this command is somewhat finicky. The extracted kernel filename may be slightly different. You may need to brew install gzip in order to get command-line tools that are compatible with the extract-ikconfig script. And you'll probably need LC_ALL=C to address locale problems.

Also note that just because you can access the images doesn't mean that you can modify them and expect them to work. If you want to do that, you'll need to take Android Verified Boot into account. See https://android.googlesource.com/platform/external/avb/+/master/README.md for more details.


If you enjoyed this post, please let me know on Twitter or Bluesky.

Posted September 24, 2025.

Tags: #aosp, #linux, #mac