|
|
@@ -0,0 +1,39 @@
|
|
|
+#!/bin/bash
|
|
|
+###################################################################
|
|
|
+### ###
|
|
|
+### Move a running guest's virtual disk file using virsh's ###
|
|
|
+### blockcopy --pivot feature. ###
|
|
|
+### ###
|
|
|
+### - Works for guests with a single virtual disk ###
|
|
|
+### - Still requires manual editing of the domain's dumped ###
|
|
|
+### xml file with the new absolute path of the virtual ###
|
|
|
+### disk before running virsh define and removing the ###
|
|
|
+### original virtual disk. (Will try to implement these ###
|
|
|
+### steps within the script in the future) ###
|
|
|
+### /mhutchinson ###
|
|
|
+### Last updated 11-18-2024. ###
|
|
|
+### ###
|
|
|
+###################################################################
|
|
|
+
|
|
|
+echo -e "Usage: $0 DOMNAME"
|
|
|
+
|
|
|
+DISKLIST=$(virsh domblklist $1 --details | grep -v cdrom | grep file | awk '{ print $4 }')
|
|
|
+
|
|
|
+echo -e "Disk list:\n"
|
|
|
+echo -e "$DISKLIST\n"
|
|
|
+for i in $DISKLIST; do
|
|
|
+ echo "just filename:";
|
|
|
+ basename $i ; JUSTFILENAME=$(basename $i)
|
|
|
+ OLDFULLPATH=$i;
|
|
|
+ echo "full path again:" $OLDFULLPATH;
|
|
|
+ read -p 'Enter NEW ABSOLUTE PATH (w/o filename):' NEWPATH;
|
|
|
+ echo "NEWPATH is "$NEWPATH;
|
|
|
+ echo "NEW ABSOLUTE PATH with FILENAME is "$NEWPATH"/"$JUSTFILENAME;
|
|
|
+ echo "DOM's xml file has been dumped to this dir. Remember to change it AFTER the pivot completes." ;
|
|
|
+ virsh dumpxml --inactive $1 > $1.xml;
|
|
|
+ virsh undefine $1;
|
|
|
+ echo "Starting blockcopy on disk "$JUSTFILENAME"...";
|
|
|
+ virsh blockcopy --domain $1 --path $OLDFULLPATH --dest $NEWPATH"/"$JUSTFILENAME --wait --verbose --pivot;
|
|
|
+ echo "Now you must change to the new abs path in the "$1".xml file, save it, then run virsh define "$1".xml and remove the old file."
|
|
|
+ echo "done"
|
|
|
+done
|