Mount qcow2 image Ubuntu

The first step to mounting your qcow2 image is to enable nbd (network block device) on your machine:

sudo modprobe nbd max_part=8

The next step is to connect your qcow2 file as an nbd device:

sudo qemu-nbd --connect=/dev/nbd0 /home/kvm/images/yourimage.qcow2

*Note that it is important to specify the full path of your qcow2 image

The next step is to fiew the partitions of your image file:

sudo fdisk /dev/nbd0 -l

Next create a directory where your can mount your image:

sudo mkdir /mnt/mymount

Next, mount the applicable partition:

sudo mount /dev/nbd0p1 /mnt/mymount/

You are now able to browse the file system of your qcow2 image and make necessary changes. Once you are done making these changes, you should execude the following commands to safely unmount your image and disconnect it from nbd:

sudo umount /mnt/mymount/

sudo qemu-nbd --disconnect /dev/nbd0