First install lvm2, ndb and qemu-common packages:
Code
yum install lvm2 nbd qemu-common
Then run this to load the nbd module:
Code
modprobe nbd max_part=16
And connect the device:
Code
qemu-nbd -c /dev/nbd0 "/home/USER/VirtualBox VMs/CentOS6/CentOS6.vdi"
Load the dm-mod module:
Run this command to scan for volume groups:
This will output something like this:
Reading all physical volumes. This may take a while...
Found volume group "vg_centos" using metadata type lvm2
In the next step we want to use what is in the quotes above. Run
this command but replace vg_centos with whatever shows in the quotes.
Code
vgchange -ay vg_centos
Then show which partitions there are:
This will output something like this:
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_root vg_centos -wi-a- 18.12g
lv_swap vg_centos -wi-a- 1.97g
In this case we want the logical volume named lv_root so run this command:
Code
mount /dev/vg_centos/lv_root /mnt/vdi -o ro,user
Now you should be able to find your disk in the /mnt/vdi folder.
Note that you must have created the /mnt/vdi folder first but you can
mount it wherever you like into an empty folder.
Some more useful tips.
You can unmount the disk:
This command will disconnect the nbd:
Code
qemu-nbd -d /dev/nbd0
After you disconnect the nbd you can unload the module: