How do I mount a qcow2 disk image?

47,958

Solution 1

A quick google search turns up the qemu-nbd program, mentioned here. It is part of the qemu-kvm package, so you'll have to install KVM if you aren't using that already. Not sure about any direct GNOME/KDE solutions, if that is what you were looking for. Here is an example for using it:

sudo modprobe nbd
sudo qemu-nbd -c /dev/nbd0 --read-only /path/to/image.qcow2
udisksctl mount -b /dev/nbd0p1

Solution 2

There's also libguestfs, but it's not yet available from official repositories1. There are binaries in libguestfs.org though.

Share:
47,958

Related videos on Youtube

RusGraf
Author by

RusGraf

My goal here is usually to document.

Updated on September 17, 2022

Comments

  • RusGraf
    RusGraf almost 2 years

    I have a QEMU virtual machine that uses a qcow2 disk image.

    How can I mount its filesystem without powering on the virtual machine?

  • RusGraf
    RusGraf almost 14 years
    The xmount manual states that only EWF and raw disk images can be used.
  • RusGraf
    RusGraf almost 14 years
    Looks like qemu-nbd is the best way to go, as long as I remember to modprobe nbd first. qemu-nbd fails silently if this module has not been loaded!
  • Jonathon Reinhart
    Jonathon Reinhart over 7 years
    I wrote a little tool to wrap this up: github.com/JonathonReinhart/qcow2-explore
  • Twirrim
    Twirrim over 6 years
    A qcow2 image is not a raw image, and can't be mounted through either of those approaches.
  • myrdd
    myrdd over 4 years
    qemu-nbd is part of the qemu-utils package, so no need to install KVM
  • ivo
    ivo over 3 years
    I must appreciate this very nice, yet simple and powerful answer. It helped me to resolve my issue in a couple of minutes. Thank you Tim Yates.