0

How to Mount and Browse a LVM qcow2 Image

Posted by simon on 2015-06-29 in Guides |

This guide will show you how to mount a qcow2 image and also browse the qcow2 image if it is an LVM partition

  1. You need to add the nbd module to your machine
    modprobe nbd max_part=63
  2. You then need to mount the qcow2 image to the NDB device driver
    qemu-nbd -c /dev/nbd0 /path/to/image.qcow2
  3. You can now check for the partitions by using the following command
    fdisk -l /dev/nbd0 and you should get a list like the one below

    Disk /dev/nbd0: 34.4 GB, 34359738368 bytes
    255 heads, 63 sectors/track, 4177 cylinders, total 67108864 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000064e8
         Device Boot      Start         End      Blocks   Id  System
    /dev/nbd0p1   *        2048      499711      248832   83  Linux
    /dev/nbd0p2          501758    67106815    33302529    5  Extended
    /dev/nbd0p5          501760    67106815    33302528   8e  Linux LVM
  4. You next need to let the computer scan for the LVM volumn by using vgscan and you should get something similar to this following output below:
    Reading all physical volumes.  This may take a while...
    Found volume group "Multicraft-vg" using metadata type lvm2
    Found volume group "pve" using metadata type lvm2
  5. Once scanned, you will then need to add the LVM to your computer and set as Active, this can be done by using vgchange -ay and you should get the similiar output as below:
    2 logical volume(s) in volume group "Multicraft-vg" now active
    4 logical volume(s) in volume group "pve" now active
  6. Now the LVM is found, only thing left to do is mount the LVM to a folder
  7. First make a folder mkdir /mnt/image
  8. Next mount the LVM by doing something like this:
    mount /dev/VolGroupName/LogVolName /mnt/image
  9. and you should be able to go to /mnt/image  and your files will be there!
  10. Once you have finished with the files, you need to unmount the folder:
    umount /mnt/image
  11. Also dont forget to make the LVM inactive:
    vgchange -an VolGroupName
  12. And finally detach the image from the computer all together:
    qemu-nbd -d /dev/nbd0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2014-2024 Simon Smith All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.