This is a little sysadmin tip that I had to use today and took me a while to piece together. If you have a virtual machine disk (e.g. from kvm) that has LVM drives and want to mount a single partition on another machine, its not so straightforward (unless you know). Here is how to do it!
- Start by creating an appropriate loop setup and creating a device map from the partition table
-
losetup /dev/loop0 dinsdale.img
-
kpartx -a /dev/loop0
-
- Now we need to scan the volume groups so we can activate them:
-
vgscan
- This will say something like:
-
Reading all physical volumes. This may take a while... Found volume group "vg_root" using metadata type lvm2
- Now we need to activate the volume group (in my case vg_root):
-
vgchange -ay vg_root
-
-
- Scan the linux volumes to find the one that you want to mount. This may or may not have the same name as your volume group above.
-
lvdisplay
-
- Mount the appropriate lvgroup in a tmp directory:
-
mount /dev/vg_root /mnt/dinsdale/
-