X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Flvm.c;h=284e58016c496666118af5bad74ae9a633e0f87c;hb=16da7589e91b0030fb5564553447f80b97c0b18c;hp=216c9c44ab5d6bc7938947cf5e85dad9e1c7b6fc;hpb=fea2e61ac1129a2f01036d4dfbee8947f3d00886;p=libguestfs.git diff --git a/daemon/lvm.c b/daemon/lvm.c index 216c9c4..284e580 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);