I download Android Emulator M1 Initial Preview from https://github.com/google/android-emulator-m1-preview/releases

Inside the .app file I found api30-gphone-arm64-v8a/system.img which isn't a yaffs2 nor sparse file:

./unyaffs2 /tmp/android-wip/system.img /tmp/android-wip/system-img/
unyaffs2-0.2.8: image extracting tool for YAFFS2
image size (3232759808) is NOT a mutiple of 2048 + 64

operation incomplete
files contents may be broken
simg2img system.img.ext4 system.img
Invalid sparse file format at header magic
Failed to read sparse file

So what is the format of such file?

Updates: Based on the direction from @Robert, I can see that the file is an fdisk image:

$ fdisk -lu system.img
Disk system.img: 3,1 GiB, 3232759808 bytes, 6313984 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 41F73643-DBCB-41A1-A27E-9FDB53578618

Device      Start     End Sectors Size Type
system.img1  2048    4095    2048   1M Linux filesystem
system.img2  4096 6311935 6307840   3G Linux filesystem

Now, it's unclear what format of the partition inside, because mount it as a regular linux partition fails:

$ sudo mount -o loop,offset=1048576 system.img /mnt/android-1
mount: /mnt/android-1: wrong fs type, bad option, bad superblock on /dev/loop17, missing codepage or helper program, or other error.

gparted also doesn't understand the partition:

enter image description here

  • 2
    The file is not a partition but a whole disk. You can open it with fdisk and see that it contains multiple partitions.
    – Robert
    Commented Apr 1, 2021 at 11:12
  • @Robert Thanks. Do you have further information on what kind of format for each partition? It doesn't seem to be ext4 partitions? Commented Apr 2, 2021 at 9:34

1 Answer 1


wrong offset, partition start at sector 4096. you can use kpartx instead

newer android running dynamic partitions. the super partition can be unpacked with Dynamic Partition Tools

furthermore partitions are flagged as read-only, therefore mount -r flag is required

sudo -i

git clone https://github.com/AndroidDumps/Firmware_extractor.git
PATH=$PATH:$(realpath Firmware_extractor/tools/Linux/bin)

mkdir -p /mnt/android-1/system_root ../extracted
kpartx -av system.img
lpunpack -p system /dev/mapper/loop2p2 ../extracted

mount -t ext4 -o loop,ro,noexec,noload,noatime ../extracted/system.img /mnt/android-1/system_root
thunar /mnt/android-1/system_root

(or whatever kpartx tell you 2nd partition is mapped)

in case you need to make ext4-dedup/logical partition writeable, increase partition first, then duplicate shared blocks

cd ../extracted
dd if=/dev/zero bs=1G seek=1 count=0 of=system.img
resize2fs system.img 1G
e2fsck -E unshare_blocks system.img

you should be able to mount -w afterwards

re-packing requires new vbmeta signature with avbtool.py stored in first partition system.img1 start at sector 2048 (which goes too far here)

superrepack third-party cross-platform tool for easy unpack/repack system.img2 is recommended to automatize the whole re-packing process

you can however do it manually with lpmake (requires all partitions to be unpacked into ../extracted see above step lpunpack)

resize2fs -M system.img
e2fsck -yf system.img
lpmake --metadata-size 65536 --super-name super --metadata-slots 1 --device super:3229614080 --group main:2369171456 --partition system:readonly:787050496:main --image system=system.img --partition vendor:readonly:83619840:main --image vendor=vendor.img --partition product:readonly:1366814720:main --image product=product.img --partition system_ext:readonly:131686400:main --image system=system_ext.img --sparse --output super.img
  • It failed with this error: ``` mount -t ext4 -o loop,rw,noatime /dev/mapper/loop19p2 /mnt/android-1/system mount: /mnt/android-1/system: wrong fs type, bad option, bad superblock on /dev/loop20, missing codepage or helper program, or other error. ``` Commented Apr 4, 2021 at 7:29
  • Thanks for the enlightening answer. I was able to mount the image and changing the content inside now Commented Apr 5, 2021 at 1:22
  • 1
    you won't be able to run modified partition unless avb/dm-verity is disabled. maybe it's already sufficient to set the flag 2 in system.img1 with hex editor which will instruct to skip hashtree verification (never tested myself, but that's what magisk does) android.stackexchange.com/q/221756
    – alecxs
    Commented Apr 5, 2021 at 2:20
  • superrepack come with a warning from the author just yesterday: I have bad news for you! This tool is dangerous! Do not use please! What I have found now while checked modified partition with e2fsck, found a ton of "Multiply-claimed blocks already reassigned or cloned.", when I do e2fsck repair it got repaired but bad news is some files is deleted from partition Commented Apr 5, 2021 at 2:34
  • 1
    cat super.img > /dev/mapper/loop2p2
    – alecxs
    Commented Apr 6, 2021 at 7:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .