How to Mount qcow2 KVM/Xen/VMware VM Image

To mount qcow2, you need to mount this image as a ‘Network Block Device’.

First, enable NBD

modprobe nbd max_part=8

Now, connect the qcow2 as an NBD device

qemu-nbd --connect=/dev/nbd0 /vz/vmprivate/v1002/harddisk.hdd

Now to mount the partition, first detect the partition

fdisk /dev/nbd0 -l

Now, you may mount the partition

mount /dev/nbd0p1 /mnt

Once, all the jobs are done, you may unmount, disconnect, and remove the NBD kernel module

umount /mnt
qemu-nbd --disconnect /dev/nbd0
rmmod nbd

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.