summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-12-07 17:55:38 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-12-07 17:57:08 +0000
commit0942cab0375cb445cc8edfba87ea82a703383964 (patch)
tree7f4a3059f4d788e8c60dec3402b2cc24ec36ee49 /daemon
parent1c63d8239a9a05eeafd4e4b8c882200bc68a3109 (diff)
downloadlibguestfs-0942cab0375cb445cc8edfba87ea82a703383964.tar.gz
libguestfs-0942cab0375cb445cc8edfba87ea82a703383964.tar.xz
libguestfs-0942cab0375cb445cc8edfba87ea82a703383964.zip
ubuntu: deactivate LVs and VGs before removing them.
Even with the '-f' option, LVM on Ubuntu sometimes cannot remove active LVs and VGs. Change lvm-remove-all so it deactivates each LV and VG before removing them.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/lvm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 216c9c44..284e5801 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -322,6 +322,12 @@ do_lvm_remove_all (void)
return -1;
for (i = 0; xs[i] != NULL; ++i) {
+ /* Deactivate the LV first. On Ubuntu, lvremove '-f' option
+ * does not remove active LVs reliably.
+ */
+ (void) command (NULL, NULL, "lvm", "lvchange", "-an", xs[i], NULL);
+ udev_settle ();
+
r = command (NULL, &err, "lvm", "lvremove", "-f", xs[i], NULL);
if (r == -1) {
reply_with_error ("lvremove: %s: %s", xs[i], err);
@@ -339,6 +345,10 @@ do_lvm_remove_all (void)
return -1;
for (i = 0; xs[i] != NULL; ++i) {
+ /* Deactivate the VG first, see note above. */
+ (void) command (NULL, NULL, "lvm", "vgchange", "-an", xs[i], NULL);
+ udev_settle ();
+
r = command (NULL, &err, "lvm", "vgremove", "-f", xs[i], NULL);
if (r == -1) {
reply_with_error ("vgremove: %s: %s", xs[i], err);