summaryrefslogtreecommitdiff
path: root/remove-vm
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-12-07 10:31:36 +0200
committerLars Wirzenius <liw@liw.fi>2019-12-07 10:31:36 +0200
commita4b78a473202a50cfde613493214e7f6b808edb8 (patch)
treec736be2e11da2feb229e33759c63222cd77c1246 /remove-vm
parente4581bf39cb04bd0519e4a515395d41e766a3bd0 (diff)
downloadansibleness-a4b78a473202a50cfde613493214e7f6b808edb8.tar.gz
Change: if lvremove fails, try undoing kpartx
Diffstat (limited to 'remove-vm')
-rwxr-xr-xremove-vm5
1 files changed, 5 insertions, 0 deletions
diff --git a/remove-vm b/remove-vm
index 2ac9e53..9d1e940 100755
--- a/remove-vm
+++ b/remove-vm
@@ -25,11 +25,16 @@ remove_vm()
run_virsh undefine "$name"
fi
+
# Remove the LV, if it exists.
lvpath="/dev/$vg/$name"
if [ -e "$lvpath" ]
then
sudo lvremove --force "$lvpath"
+ else
+ # In case the LV was kpartx'd, undo that
+ sudo kpartx -dsv "$lvpath"
+ sudo lvremove --force "$lvpath"
fi
# Remove the host from /etc/hosts, if there.