I used these commands to first generate output that matches all contents of a VG:

 

# lvs -o vg_name,name,size --unit=m --noheadings | grep vgxen| awk '{print "lvcreate -n "$2" -L "$3" vg01"}
lvcreate -n lvol01 -L 1024.00m vg01
lvcreate -n xen01 -L 32768.00m vg01
lvcreate -n xen01swap -L 512.00m vg01
lvcreate -n xen02 -L 10000.00m vg01
lvcreate -n xen02swap -L 256.00m vg01
lvcreate -n xen03 -L 10240.00m vg01
lvcreate -n xen03swap -L 256.00m vg01

after running the commands from the first oneliner, I could then initate swaps and format the filesystems.

Note I used mkfs.ext3 since the original software had only created ext3 volumes.

for lv in /dev/vg01/*swap ; do mkswap $lv ; done
for lv in /dev/vg01/xen[0-9][0-9] ; do mkfs.ext3 $lv ; done

 

A script to detect if there's a plain FS in the VM file:

#!/bin/bash
for vmcfg in /etc/xen/xen[0-9][0-9] ; do
   vm=$(basename $vmcfg)
   if ! [ -b /dev/vgxen/$vm ]; then
       echo "$vm has no block device"
       continue
    fi
   if grep -v -e hvm -e ^# $vmcfg | grep -e pvgrub -e pygrub -e kernel > /dev/nu
ll ; then
      echo $vm is a pv domU, checking for ext
      tune2fs -l /dev/vgxen/$vm > /dev/null
      if [ $? = 0 ]; then
          echo "$vm is on ext3 filesystem"
      fi
   else
       echo $vm might be a HVM domU, should be moved with dd
   fi
done
  • No labels