Mount qcow2 image created by Android emulator

て烟熏妆下的殇ゞ 提交于 2020-05-13 14:11:25

问题


I'm trying to mount the userdata-qemu.img.qcow2 file created by the Android emulator. The following procedure does not work:

sudo qemu-nbd -c /dev/nbd0 ~/.android/avd/Pixel_C_API_27.avd/userdata-qemu.img.qcow2

First command runs well, but running

sudo qemu-nbd -c /dev/nbd0 ~/.android/avd/Pixel_C_API_27.avd/userdata-qemu.img.qcow2

results in this output:

Fehler: /dev/nbd0: unbekannte Partitionstabelle
Modell: Unbekannt (unknown)                                               
Festplatte  /dev/nbd0:  3146MB
Sektorgröße (logisch/physisch): 512B/512B
Partitionstabelle: unknown
Disk-Flags: 

Basically it cannot recognize a partition table in the image file. You may wonder what's the output of

fdisk /dev/nbd0 -l

so here it is:

Medium /dev/nbd0: 3 GiB, 3145728000 Bytes, 6144000 Sektoren
Einheiten: sectors von 1 * 512 = 512 Bytes
Sektorengröße (logisch/physisch): 512 Bytes / 512 Bytes
I/O Größe (minimal/optimal): 512 Bytes / 512 Bytes

As you could expect already, mounting fails of course, since no partitions can be recognized if the partition table itself cannot be recognized either. Thanks for any help!

Edit: I've just found out that the problem must have to do with Android's userdata encryption. As I've never changed any password the encryption password of the emulator's userdata partition would have to be the default one "default_password". How can I decrypt the image to be able to mount it?


回答1:


You can mount userdata-qemu.img.qcow2 using the following procedure

  1. convert the image to a raw image

    qemu-img convert -O raw userdata-qemu.img.qcow2 udata-raw.img

  2. use losetup to setup a loopback device for mounting

    sudo losetup -f -P userdata.img

  3. use losetup -l to see what device was setup

    losetup -l
    NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                DIO
    /dev/loop0         0      0         0  0 /path/to/userdata.img   0
    
  4. mount the drive

    mkdir /tmp/mnt
    sudo mount /dev/loop0 /tmp/mnt
    

Then ls /tmp/mnt/ gives

app  benchmarktest  benchmarktest64  lost+found  misc  nativetest nativetest64


来源:https://stackoverflow.com/questions/49039315/mount-qcow2-image-created-by-android-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!