Mount Android emulator images Mount Android emulator images android android

Mount Android emulator images


You've already answered your own question but I'll expand a bit.The Android sdk comes with system images, for example:

$ cd android-sdk-linux/system-images/android-15/armeabi-v7a/$ ls *.imgramdisk.img  system.img  userdata.img$ cd ~/.android/avd/<img name>.avd/$ ls *.imgcache.img  sdcard.img  userdata.img  userdata-qemu.img

Though, not all images are of the same type:

$ file *.imgcache.img:         VMS Alpha executablesdcard.img:        x86 boot sector, code offset 0x5a, OEM-ID "MSWIN4.1", sectors/cluster 4, Media descriptor 0xf8, sectors 2048000 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 3993, reserved3 0x800000, serial number 0x17de3f04, label: "     SDCARD"userdata.img:      VMS Alpha executableuserdata-qemu.img: VMS Alpha executable

Since sdcard.img contains no extra partitions, it can be mounted directly without an offset parameter (like -o loop,offset=32256):

$ fdisk -l sdcard.imgYou must set cylinders.You can do this from the extra functions menu.Disk sdcard.img: 0 MB, 0 bytes255 heads, 63 sectors/track, 0 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x00000000     Device Boot      Start         End      Blocks   Id  System$ sudo mount -o loop sdcard.img /mnt/

The other image files which are described as VMS Alpha executable are in fact yaffs2 files. As far as I'm aware they can't be mounted directly but can be extracted using the two utilities unyaffs or unyaffs2.

$ mkdir extract$ cd extract$ unyaffs ../userdata.img

or

$ unyaffs2 --yaffs-ecclayout ../userdata.img .

Note, there's another utility called simg2img which can be found in the android source tree under ./android_src/system/extras/ext4_utils/ which is used on compressed ext4 img files. However, if wrongly applied to yaffs2 images it complains with Bad magic.


If anyone ends up here looking for more information on the use of simg2img:

This is the file I needed to mount:

$ file factoryfs.img factoryfs.img: data$ unyaffs factoryfs.img Can't determine flash layout, perhaps not a yaffs2 image

And this is how I was able to mount it:

  1. Install simg2img

    • On newer versions of Ubuntu it's available as a package

      sudo apt install simg2img
    • On older versions of Ubuntu you'll need to compile it from source

      1. Install prerequisites

        sudo apt install build-essential git zlib1g-dev
      2. Download and compile source

        git clone https://android.googlesource.com/platform/system/corecd core/libsparsegcc -o simg2img -Iinclude simg2img.c sparse_crc32.c backed_block.c output_file.c sparse.c sparse_err.c sparse_read.c -lz
  2. Uncompress the sparse image file to a raw image file:

    simg2img /path/to/factoryfs.img /path/to/factoryfs.raw.img
  3. Mount the raw image file. In Ubuntu the easiest way to do this is by right-clicking the file in the Files app → Open WithDisk Image Mounter. Or using the command line:

    sudo mkdir /mnt/factoryfssudo mount /path/to/factoryfs.raw.img /mnt/factoryfs

Note: This won't work with boot.img, which is a special case:How to extract boot.img?


I wanted to unpack a NON-SPARSE ext4 image file on Windows. simg2img is for use with sparse ext4. Ext4 is not sparse by definition, that's just an option for it, yet every description of this process starts with that assumption for whatever reason. Anyway, DiskTool did this for me with zero effort, after I wasted lots of time trying to figure this out. It doesn't install any extraneous garbage either, and it works fine on Windows 10:

http://sourceforge.net/projects/androidicsjbext/