10 August, 2009

Xen: Howto mount lvm partition on host OS

After the install CentOS using xen. How do we mount the LVM partition?
1. Go to your xen domain directory.
2. Make device "loopN" point to your disk image
e.g. losetup /dev/loop0 disk.img
3. Create device map for the partitions of the disk image
kpartx -a /dev/loop0
Use lvs to see the partition information.
4. Scan volume group over all disk
vgscan
5. Activate the volume group
vgchange -ay VolGroup00
6. Then mount the partition
mount /dev/VolGroup00/LogVol00 ./mnt

Done!

And you might need to umount the LVM disk:
1. umount the directory
umount ./mnt
2. deactivate the volume group
vgchange -an VolGroup00
3. remove the partition information
kpartx -d /dev/loop0
4. Restore loop device
losetup -d /dev/loop0

No comments: