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:
- xe vm-list name-label=<vm-name>
- 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.
- xe sr-list type=lvm
- vgchange –ay VG_XenStorage-<sr-uuid>
5. List all disks in that VG group
- 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.
- kpartx –a /dev/ VG_XenStorage-<sr-uuid>/LV-<vdi-uuid>
7. Check the mapped partitions in /dev/mapper
- ll /dev/mapper
You should be able to see LV-<vdi-uuid>p<partition_number>. For example:
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
(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:
- Found volume group “system” using metadata type lvm2
10. Use the following commands to make all logical volumes in the group active:
- lvchange -ay <vg-name>
(the same VG name as you can see from the previous command)
- lvchange –ay system
11. Verify that this volume group has active logical volumes listed as follows.
You should be able to see similar output if the VG system includes 2 partitions.
- ACTIVE ‘/dev/system/root’ [7.43 GB] inherit
- ACTIVE ‘/dev/system/swap’ [512.00 MB] inherit
12. Create a directory, mount this logical volume, and access its data using the following commands:
- mkdir /mnt/partition
- mount /dev/<vg-name>/<partition> /mnt/partition
- cd /mnt/partition
(You should see the content of the partition)
1. Unmount mounted devices.
- umount /mnt/disk
2. Deactivate the logical volumes on the VG.
- vgchange –an <VG-name>
3. Delete partition mappings with kpartx.
- 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.)
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.
- fsck.ext3 /dev/<vg-name>/<partition>
- fsck.ext3 /dev/system/root