How to mount qcow2 images
Have you ever needed to access a virtual machine without starting it? Perhaps you just needed few important files. In case it is in a qcow2 (qemu/kvm) format this can be easily done by:
qemu-nbd -c /dev/nbd0 vm.qcow2.img
mount /dev/nbd0p1 /mnt/VirtualM
Naturally, you would first need to load the nbd module.
If the image is not in the qcow2 format but in VMware format (vmdk) it can be converted to qcow2 like this:
kvm-img convert -O qcow2 disk1.vmdk disk1.qcow2
Later you can disconnect the image with (again as the root):
qemu-nbd -d /dev/nbd0
Just, don’t forget first to unmount it:
umount /mnt/virtualM