Access to logical volumes in domU from the dom0

dale's picture

I currently run a Fedora 8 dom0 with Fedora 9 domU's primarily. I'm working on exactly how I wish to configure the disk layout, but here is how to configure each domU on it's own logical volume, configure further logical volumes within that domU, and how to access those logical volumes from the host dom0.

The domU's live inside a VG across the SAN named VGSanLun10. Each domU gets a dedicated LV with a unique name. I generate a private MAC addresses for the domU by appending the unix time in hex to 'AA00'. I could use the name of the domU as the name of the LV, but that could change and hex numbers are more sexy, this unique identifier makes for a good string to put in the LV name.

So, domU with MAC AA00485BE004 gets a dom0 LV named LVDomUAA00485BE004 on VG VGSanLun10. Inside this LV block device the domU names its VG VGDomU. It is important that this VG have a name that is distinct from any VG found in dom0. Otherwise things will get ugly when you try to access domU volume group on dom0.

Here's the config I'm currently using.

  • Assuming in the dom0 you create a LV for use by the domU thusly:

   lvcreate --name 'LVDomUAA00485BE004' --size '10G' 'VGSanLun10'
  • And assuming in the domU you split that 10G up in kickstart thusly:
   zerombr
   clearpart --all --initlabel
   # raw partition for boot
   part /boot --fstype ext3 --size=100
   # physical volume on remainder
   part pv.01 --size=1 --grow
   # LVM on physical volume - make sure VG name is not used in dom0
   volgroup VGDomU pv.01
   logvol /     --fstype=ext3 --name=LVRoot --vgname=VGDomU --size=512
   logvol /var  --fstype=ext3 --name=LVVar  --vgname=VGDomU --size=1024
   logvol /usr  --fstype=ext3 --name=LVUsr  --vgname=VGDomU --size=2048
   logvol /home --fstype=ext3 --name=LVHome --vgname=VGDomU --size=100
   logvol swap  --fstype swap --name=LVSwap --vgname=VGDomU --size=512
   # install grub
   bootloader --location=mbr --driveorder=xvda --append="console=hvc0"
  • When domU is down, you may read from the dom0 command line thusly:
   kpartx -av /dev/VGSanLun10/LVDomUAA00485BE004
   # informative trivia for before/after comparison
   lvs
   vgscan
   # it's assumed VGDomU is not used in the dom0 LVM config
   vgchange -ay VGDomU
   mkdir -p /mnt/LVDomUAA00485BE004
   mount /dev/mapper/VGDomU-LVRoot /mnt/LVDomUAA00485BE004
   mount /dev/mapper/VGDomU-LVUsr  /mnt/LVDomUAA00485BE004/usr
   mount /dev/mapper/VGDomU-LVVar  /mnt/LVDomUAA00485BE004/var
   mount /dev/mapper/VGDomU-LVHome /mnt/LVDomUAA00485BE004/home
   mount /dev/mapper/LVDomUAA00485BE0041 /mnt/LVDomUAA00485BE004/boot
  • Do what you need to do then besure to unmount and deactivate before booting domU again:

   umount /mnt/LVDomUAA00485BE004/usr
   umount /mnt/LVDomUAA00485BE004/var
   umount /mnt/LVDomUAA00485BE004/home
   umount /mnt/LVDomUAA00485BE004/boot
   umount /mnt/LVDomUAA00485BE004
   vgchange -an VGDomU
   kpartx -dv /dev/VGSanLun10/LVDomUAA00485BE004