[CentOS] how to access lvm inside lvm

Fri Apr 29 22:25:44 UTC 2011
Ross Walker <rswwalker at gmail.com>

On Apr 29, 2011, at 6:05 PM, Peter Peltonen <peter.peltonen at gmail.com> wrote:

> I have a centos 5.6 server that has xen domUs installed on their on
> logical volumes. These logical volumes contain their own volume groups
> and again their own logical volumes. I want to access the domU logical
> volumes and tried this:
> 
> [root at kr ~]# fdisk -l /dev/VolGroup00/LogVol02
> 
> Disk /dev/VolGroup00/LogVol02: 274.8 GB, 274877906944 bytes
> 255 heads, 63 sectors/track, 33418 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
> 
>                    Device Boot      Start         End      Blocks   Id  System
> /dev/VolGroup00/LogVol02p1   *           1          13      104391   83  Linux
> /dev/VolGroup00/LogVol02p2              14       16709   134110620
> 8e  Linux LVM
> 
> [root at kr ~]# kpartx -a /dev/VolGroup00/LogVol02
> [root at kr ~]# ls -l /dev/mapper/
> total 0
> crw------- 1 root root  10, 62 Apr 26 02:19 control
> brw-rw---- 1 root disk 253, 12 Apr 30 00:45 LogVol02p1
> brw-rw---- 1 root disk 253, 13 Apr 30 00:45 LogVol02p2
> 
> But when I try make the domU volumegroup accessible I run into problems:
> 
> [root at kr ~]# vgscan
>  Reading all physical volumes.  This may take a while...
>  WARNING: Duplicate VG name VolGroup00: Existing
> hxNFYw-c1Z6-DB99-SiiK-yRas-eXiI-1w27Z0 (created here) takes precedence
> over KmwQTQ-jT19-lvvu-H6d0-i4T3-s5Jw-JHnx0M
>  WARNING: Duplicate VG name VolGroup00: Existing
> hxNFYw-c1Z6-DB99-SiiK-yRas-eXiI-1w27Z0 (created here) takes precedence
> over KmwQTQ-jT19-lvvu-H6d0-i4T3-s5Jw-JHnx0M
>  Found volume group "VolGroup00" using metadata type lvm2
>  Found volume group "VolGroup00" using metadata type lvm2
> 
> How can I now vgchange to the domU volume group as vgchange does not
> take the UUID as an argument, just the volume group name...?

That's why I use hostnames instead of generic volume group names.

You could vgrename the volume, but the domU won't boot afterwards unless you rename it back and I don't know if it will let you if the vg name already exists.

LVM should really use the UUID if the vg name collides or allow it to be imported under a different name temporarily.

You could rename your system vg and of course change fstab to match and remake the initrd, then you would be able to load one domU vg at a time.

-Ross