How to mount a qcow2 image with qemu-nbd

Submitted by Jeff on Sat, 01/09/2018 - 10:05

Mount a qcow2 image

modprobe nbd max_part=8

Example is self-explanatory. Using a shutdown and backed up qcow2 VM disk image:

qemu-nbd -c /dev/nbd1 /var/lib/libvirt/images/new-ff.qcow2

Naturally, there should be an existing mount point, and check to see which partition to use. I.e. ndb1p1 is the first partition, equal to /dev/sda1:

mount /dev/nbd1p1 /mnt/new-ff

Unmount a qcow2 image (NB. Or you will corrupt the image if you start the VM!)

umount /mnt/new-ff

qemu-nbd -d /dev/nbd1