Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu - Mount Qcow2 Image

Sometimes things go wrong and you need to access the files stored on your qcow2 disk images from the host directly, rather than through the VM that uses it (such as in cases where the VM doesn't boot).

This tutorial will show you how to mount your qcow2 disk images to a local folder on Ubuntu 16.04.

Steps

Install necessary packages (around 50MB for me)

sudo apt install libguestfs-tools -y

Now mount the disk image:

sudo guestmount -a \
  /path/to/qcow2/disk/image.qcow2 \
  -m /dev/sda \
  /path/to/folder/to/mount/to

The -m /dev/sda specifies the partition within the qcow2 disk image that you wish to mount. You may need to change this to /dev/sda1 or /dev/sdb etc. Don't worry if you dont know this, run the command and if it fails, you will be given some helpful alternative suggestions.

References

Last updated: 30th April 2024
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch