Mounting Volumes within a Logical Volume Device

From Zanecorpwiki

Jump to: navigation, search

The goal, mount a logical volume within a logical volume device. In other words:

  • you have LVM
  • you've set up some of that LVM as as a block device (i.e., acts as a classical HD)
  • the block device partition itself contains partitions with some file system
  • you want to mount one of those inner partitions

This occurs most often when using Xen. You set up LVM devices for use by the virtual hosts and you desire to mount the virtual host's partitions from the Dom0.

The following assumes:

  • 'vg1', located in '/dev/vg1' is the volume group
  • 'devicevolume' is the volume
# create a snapshot so we don't screw up the real drive
lvcreate -n devicevolume_s -L 1G -s /dev/vg1/devicevolume
# get the mappings for the partitions within the device
kpartx -l /dev/vg1/devicevolume_s
# there may be multiple partitions; the size of the numbers may tell you which one you want
kpartx -a /dev/vg1/devicevolume_s
# if you had two partitions, this will create entries like:
# /dev/mapper/vg1-devicevolume_s1
# /dev/mapper/vg1-devicevolume_s2
mount /dev/mapper/vg1-devicevolume_s2 /mnt
# and when you are done
umount /mnt
kpartx -d /dev/vg1/devicevolume_s
lvremove /dev/vg1/devicevolume_s
Personal tools