Custom Search

SUBSCRIBE

SUBSCRIBE : 300 + Free Video Tutorials Programming (Python, golang, Julia), DevOps

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

5 comments:

  1. http://www.linux-sxs.org/storage/fedora2ubuntu.html

    ReplyDelete
  2. Error
    =====
    # sudo chroot /mnt/t2
    chroot: failed to run command ‘/bin/bash’: Permission denied

    Fix
    ====
    sudo mount /dev/i1-vg/root /mnt/t2

    http://mandrivausers.org/index.php?/topic/36838-why-cant-i-perform-chroot-to-mandriva-from-ubuntu/

    ReplyDelete


  3. Boot Ubuntu.
    Install lvm2:

    $ sudo apt-get install lvm2

    Load the necessary module(s):

    $ sudo modprobe dm-mod

    Scan your system for LVM volumes and identify in the output the volume group name that has your Fedora volume (mine proved to be VolGroup00):

    $ sudo vgscan

    Activate the volume:

    $ sudo vgchange -ay VolGroup00

    Find the logical volume that has your Fedora root filesystem (mine proved to be LogVol00):

    $ sudo lvs

    Create a mount point for that volume:

    $ sudo mkdir /mnt/fcroot

    Mount it:

    $ sudo mount /dev/VolGroup00/LogVol00 /mnt/fcroot -o ro,user

    Copied my files.

    ReplyDelete
  4. Ubuntu Linux How to exit from chroot
    http://fosshelp.blogspot.com/2014/07/ubuntu-linux-how-to-exit-from-chroot.html

    ReplyDelete