TMPDEV=/dev/mapper/$TMPDM
TMPDM2=tmpbar
TMPDEV2=/dev/mapper/$TMPDM2
-METADATASIZE=3.5m
+METADATASIZE=8128k
# - pvresize the old PV to half the space
pvresize --setphysicalvolumesize=${HALFSIZETiB}t $DISK
for m in sorted(mm.iterkeys()): print m'
}
-lvsleft () {
- lvs -o name,devices xenvg \
- | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"
-}
-
vmstolvs () {
perl -pe 's/^/d_/;s/$/_hda/'
}
| perl -lne '$total += $_; END { print $total; }'
}
+lvsleft () {
+ lvs -o name,devices $VG \
+ | perl -lane "print \$F[0] if (\$F[1] =~ m|$DISK|)"
+}
+
movelv () {
echo pvmoving $VG/$1...
pvmove -i 10 -n $VG/$1 $2
# - pvremove the old PV
-vgreduce $VG $DISK
-pvremove $DISK
+LVM_SYSTEM_DIR=lvm vgreduce $VG $DISK
+dmsetup create $TMPDM2 --table "0 $((2 * 1024 * 20)) linear $DISK 0"
+pvremove $TMPDEV2
# - pvcreate a new PV in the old space,
# with --setphysicalvolumesize <half size>
# and with --metadatasize <huge> (the point of this exercise)
shortsize=$(python -c "print $HALFSIZETiB - 0.01")t
-dmsetup create $TMPDM2 --table "0 $((2 * 1024 * 4)) linear $DISK 0"
pvcreate $TMPDEV2 --setphysicalvolumesize $shortsize --metadatasize $METADATASIZE
dmsetup remove $TMPDM2
pvscan
-vgextend $VG $DISK
+LVM_SYSTEM_DIR=lvm vgextend $VG $DISK
# - pvmove all the LVs back
+# Doing this part with CLVM again.
+
+lvsleft () {
+ lvs -o name,devices $VG \
+ | perl -lane "print \$F[0] if (\$F[1] =~ m|$TMPDEV|)"
+}
+
+movelv () {
+ echo pvmoving $VG/$1...
+ lvchange -an $VG/$1
+ pvmove -i 10 -n $VG/$1 $2
+ lvchange -ay $VG/$1
+}
+
+movestuff () {
+ date
+ while read lv; do
+ echo MOVING: $lv >>/var/log/lvm2.log
+ movelv $lv $TMPDEV
+ date
+ done
+}
+
+moveall () {
+ date
+ for lv in $(lvsleft); do
+ echo MOVING: $lv >>/var/log/lvm2.log
+ movelv $lv $TMPDEV
+ date
+ done
+}
+
#FOREACH host:
-for lv in $(lvs -o lv_name --noheadings $VG); do
- movelv $VG/$lv $TMPDEV
-done
+#set logging in /etc/lvm/lvm.conf
+while sleep 1; do
+ echo MARK: $(date) >>/var/log/lvm2.log
+done &
+lvsleft | grep -xf <(invirt-listvms | yamlkeys | vmstolvs) \
+ | movestuff >>/root/lvm/movelv.log 2>&1
+moveall >>/root/lvm/movelv.log 2>&1
+while true; do
+ kinit -k -45
+ sh -x status.sh 2>&1 | zwrite -c xvm-auto -i pvmove -O auto
+ sleep 1800
+done &
#done
+#suffix=.return-1; mv /var/log/lvm2.log lvm/lvm2.$suffix.log; mv lvm/movelv{,.$suffix}.log
+
# hopefully empty:
lvs $VG -o lv_name,devices | grep $TMPDEV
# if not, do some more movelv
# - pvremove the temporary PV
vgreduce $VG $TMPDEV
pvremove $TMPDEV
+#FOREACH host:
dmsetup remove $TMPDM
+#done
# - pvresize the new PV to use the whole space
pvresize $DISK