Wednesday, December 14, 2011

howto mount qcow2 images

Sometimes you need a way to access a virtual machine without starting it. It might dosn't work anymore and there are still some important files on it or you are simple just to lazy to start, login and change/look whatever you want to change/look for.
In case of lvm it easy: There are "real" partitions on the volume so its dead simple to mount and access the guest harddisk. It's also simple with raw files which works with loop devices thus with losetup.
Another story are qcow2 files.
For them you need qemu-nbd which comes with app-emulation/qemu-kvm and a kernel modul called nbd which you will find under: "Device Drivers --> Block devices --> Network block device support". If you didn't compile it yet (as modul) compile it now.
Next you have to load the modul with following parameters:

modprobe nbd max_part=8

You have to set the max_part because the default is 0 and usually you have more than 1 partition on a guest system. After that you can mount the image with:

qemu-nbd -c /dev/nbd0 guest.img
mount /dev/nbd0p1 /mnt/guest

That's all. With qemu-nbd -d you can disconnect the image finally, though you have to unmount it first.

3 comments:

  1. Never say there is nothing beautiful in the world anymore. There is always something to make you wonder in the shape of a tree, the trembling of a leaf. See the link below for more info.


    #anymore
    www.ufgop.org

    ReplyDelete
  2. Reading your article is such a privilege. It does inspire me, I hope that you can share more positive thoughts. Visit my site too. The link is posted below.

    n8fan.net

    www.n8fan.net

    ReplyDelete
  3. I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


    edupdf.org

    ReplyDelete