Custom Search
Showing posts with label qcow2. Show all posts
Showing posts with label qcow2. Show all posts

Monday, June 30, 2014

How to mount a qcow2 disk image on Ubuntu


http://www.randomhacks.co.uk/how-to-mount-a-qcow2-disk-image-on-ubuntu/

Step 0 - Install qemu-kvm

sudo apt-get install qemu-kvm

Step 1 – Enable NBD on the Host
You will need to enable the nbd (network block device) kernel module on the host.

sudo modprobe nbd max_part=8



Step 2- Connect the QCOW2 as network block device
Use qemu-nbd to connect your qcow2 file as a network block device. Note: You will need to specify the full path of qcow2 file even if you are the directory of the qcow files.

sudo qemu-nbd --connect=/dev/nbd0 /mnt/kvm/wordpress-sites.qcow2

Step 3 – Find The Virtual Machine Partitions
You can find a list of the partitions on the vm using the following command

sudo fdisk /dev/nbd0 -l


Step 4 – Mount the partition from the virtual machine.
For example, I want to mount partition 1 and therefore run:

sudo mount /dev/nbd0p1 /mnt/somepoint/

Step 5 – Browse Your VM
You can then just browse the files in mnt/somepoint/

Step 6 - Afterwards unmount:

sudo umount /mnt/somepoint/

Step 7 - Then disconnect the disk:

sudo qemu-nbd --disconnect /dev/nbd0