Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

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

share|improve this question

4 Answers 4

up vote 4 down vote accepted

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.

share|improve this answer
    
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! –  ændrük Sep 24 '10 at 16:03
    
That's unfortunate. You should be able to add nbd to /etc/modules, anyway. –  Tim Yates Sep 24 '10 at 16:54

you can directly mount as a normal mount like this

mount /dev/sdb1 /mount-point

But if u have n number of device mean you want again mount it to another directory for that you can follow this one:

Mounting a partition from raw image is pretty simple:

losetup /dev/loop0 image.img
kpartx -a /dev/loop0
mount /dev/mapper/loop0p1 /mnt/image
share|improve this answer

There's also libguestfs, but it's not yet available from official repositories [1]. There are binaries in http://libguestfs.org/download/binaries/ though.

[1] https://bugs.launchpad.net/ubuntu/+bug/667346

share|improve this answer
    
While libguestfs looks really nice, but is heavyweight. It has a ton of dependencies (It recommends up to 55 dependencies, and installs an entire supermin appliance. –  Stefan Lasiewski Mar 4 '13 at 5:53

xmount can make the disk images of some VMs look like a raw disk (which can then be partitioned with losetup, and the partitions mounted). I don't know if it supports qcow2, however.

share|improve this answer
    
The xmount manual states that only EWF and raw disk images can be used. –  ændrük Sep 21 '10 at 2:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.