2 exit 1 #Not actually a script.
8 TMPDEV=/dev/mapper/$TMPDM
10 TMPDEV2=/dev/mapper/$TMPDM2
13 # - pvresize the old PV to half the space
14 pvresize --setphysicalvolumesize=${HALFSIZETiB}t $DISK
16 # - dmsetup create a device in the latter half
17 dmstart=$(python -c "print int(($HALFSIZETiB + 0.01) * 1024 * 1024 * 1024 * 2)")
18 dmlen=$(python -c "print int(($HALFSIZETiB - 0.02) * 1024 * 1024 * 1024 * 2)")
20 dmsetup create $TMPDM --table "0 $dmlen linear $DISK $dmstart"
23 # - pvcreate a temporary PV on the new device
26 # - vgextend with the temporary PV
29 # - pvmove all the LVs to the temporary PV
31 # for lv in $(LVs for running VMs on this host); do
32 # #some lvchange -a commands
33 # pvmove -n $lv <oldpv> <newpv>
34 # #possibly more lvchange -a to restore old state
43 #touch /etc/invirt/nocreate
45 #machines=$(invirt-listvms | perl -lne 'print if s/^([^ ]*):.*/$1/')
46 #lvs=$(echo $machines | perl -lpe "s|^|$VG/d_|; s|$|_hda|")
47 for lv in $(lvs -o lv_name --noheadings $VG); do
53 lvs $VG -o lv_name,devices | grep $DISK
54 # if not, do some more movelv
56 # This is possible if some LVs were used on more than one host during
60 # - pvremove the old PV
64 # - pvcreate a new PV in the old space,
65 # with --setphysicalvolumesize <half size>
66 # and with --metadatasize <huge> (the point of this exercise)
67 shortsize=$(python -c "print $HALFSIZETiB - 0.01")t
68 dmsetup create $TMPDM2 --table "0 $((2 * 1024 * 4)) linear $DISK 0"
69 pvcreate $TMPDEV2 --setphysicalvolumesize $shortsize --metadatasize $METADATASIZE
70 dmsetup remove $TMPDM2
74 # - pvmove all the LVs back
77 for lv in $(lvs -o lv_name --noheadings $VG); do
78 movelv $VG/$lv $TMPDEV
83 lvs $VG -o lv_name,devices | grep $TMPDEV
84 # if not, do some more movelv
86 # - pvremove the temporary PV
91 # - pvresize the new PV to use the whole space