How To Mount a Linux LVM Partition in a XenServer Host Document ID: CTX117791? / Created On: Aug 1, 2008 / Updated On: Aug 11, 2008 Average Rating: not yet rated View products this document applies to link to products this document applies to


This article describes how to mount a Linux Logical Volume Manager (LVM) partition located inside a virtual disk (VDI) in a XenServer Host.

If a Linux Virtual Machine (VM) with an LVM partition crashes, then the LVM partition cannot be accessed directly with kpartx. Red Hat Enterprise Linux (RHEL) 5 by default uses LVM for installing the root partition.


Citrix Xen Enterprise Server 4.1

Virtual Machine stored on local LVM storage.


1. Check for the universal unique identifier (UUID) of the VM using the following commands:

  1. xe vm-list name-label=<vm-name>
  2. xe vm-disk-list uuid=<vm-uuid>

(You will need the VDI-UUID later as this is the disk which has the LVM partition or partitions.)

2. Use the kpartx command to create loop devices for the partitions inside the LV volume.

3. Find out the LV volume file that is related to the particular VDI listed above.

  1. xe sr-list type=lvm

4. Use the SR-UUID where your VDI is located to find out the volume group (VG) group and activate all LVs? in that group.

  1. vgchange –ay VG_XenStorage-<sr-uuid>

5. List all disks in that VG group

  1. ll /dev/VG_XenStorage-<sr-uuid>

6. Now map the LV volume with the kpartx command. This is the VDI disk of the particular VM.

  1. kpartx –a /dev/ VG_XenStorage-<sr-uuid>/LV-<vdi-uuid>

7. Check the mapped partitions in /dev/mapper

  1. ll /dev/mapper

You should be able to see LV-<vdi-uuid>p<partition_number>. For example:

  1. LV-c4d1f0af-b0c4-413c-8832-2c1bfd90d118p1
  2. LV-c4d1f0af-b0c4-413c-8832-2c1bfd90d118p2

8. The following command scans partitions for LVM and adds this new volume group to the XenServer Host. Run the following command to see the VG name related to /dev/mapper

  1. pvscan

9. Run the following command to see all the VGs? recognized

  1. vgscan

(You should see same VG name as it was inside the VM.) For example:

If your VG inside the VM was named as system, you should see a similar row:

  1. Found volume group “system” using metadata type lvm2

10. Use the following commands to make all logical volumes in the group active:

  1. lvchange -ay <vg-name>

(the same VG name as you can see from the previous command)

For example:

  1. lvchange –ay system

11. Verify that this volume group has active logical volumes listed as follows.

  1. lvscan

You should be able to see similar output if the VG system includes 2 partitions.

  1. ACTIVE ‘/dev/system/root’ [7.43 GB] inherit
  2. ACTIVE ‘/dev/system/swap’ [512.00 MB] inherit

12. Create a directory, mount this logical volume, and access its data using the following commands:

  1. mkdir /mnt/partition
  2. mount /dev/<vg-name>/<partition> /mnt/partition
  3. cd /mnt/partition
  4. ls

(You should see the content of the partition)

Reverse Procedure

1. Unmount mounted devices.

  1. umount /mnt/disk

2. Deactivate the logical volumes on the VG.

  1. vgchange –an <VG-name>

3. Delete partition mappings with kpartx.

  1. kpartx –d /dev/ VG_XenStorage-<sr-uuid>/LV-<vdi-uuid>

(This is same command as above except the option which has changed from “-a” to “-d”.)

(Note that you have to deactivate all LV in the group otherwise the command fails.)

More Information

To prevent file system errors, you may use check disk before you mount the partition (before you proceed with step 9 in this guide). This applies only to EXT3 file systems.

  1. fsck.ext3 /dev/<vg-name>/<partition>

For example:

  1. fsck.ext3 /dev/system/root
Stránka naposled modifikovaná 30.03.2009, 16:19