Mount partition from qcow2-image

It’s surprisingly easy if you have the right tools. That would be:

  • The kernel module nbd (Network Block Device)
  • qemu (specifically qemu-nbd)

To expose the whole image as /dev/nbd0:

# qemu-nbd -c /dev/nbd0 </path/to/qcow2>

If you only want a specific partition:

# qemu-nbd -c /dev/nbd0 -P 2 </path/to/qcow2>

gives you the 2nd Partition on /dev/nbd0. If it contains a valid filesystem, mount it with:

# mount /dev/nbd0 /mnt/point

To get rid of it:

  • Unmount it
  • kill the according qemu-nbd process

Share and enjoy!