问题
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
convert the image to a raw image
qemu-img convert -O raw userdata-qemu.img.qcow2 udata-raw.img
use
losetup
to setup a loopback device for mountingsudo losetup -f -P userdata.img
use
losetup -l
to see what device was setuplosetup -l NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO /dev/loop0 0 0 0 0 /path/to/userdata.img 0
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