[pve-devel] [PATCH storage 1/2] lvm: ignore "activation skip" LV flag during LV activation

Friedrich Weber f.weber at proxmox.com
Thu Jan 11 16:03:31 CET 2024

LVs with the "activation skip" flag (can be set via `lvchange -ky`)
are only activated if `-K` is passed to the activation command. In the
next major release, we intend to set the "activation skip" flag for
newly created LVs. The goal is to prevent LVs from being
auto-activated after boot, and thus fix bug #4997.

In preparation for this future change, adjust activation commands
issued by the LVM plugin to include the `-K` flag. For LVs without the
"activation skip" flag, passing the `-K` flag during activation has no
effect, so it should be harmless to always provide it.

[1] https://bugzilla.proxmox.com/show_bug.cgi?id=4997

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Signed-off-by: Friedrich Weber <f.weber at proxmox.com>
 src/PVE/Storage/LVMPlugin.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 4b951e7..66b42de 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -342,7 +342,7 @@ sub lvcreate {
 	$size .= "k"; # default to kilobytes
-    my $cmd = ['/sbin/lvcreate', '-aly', '-Wy', '--yes', '--size', $size, '--name', $name];
+    my $cmd = ['/sbin/lvcreate', '-aly', '-K', '-Wy', '--yes', '--size', $size, '--name', $name];
     for my $tag (@$tags) {
 	push @$cmd, '--addtag', $tag;
@@ -422,7 +422,7 @@ sub free_image {
 	print "successfully removed volume $volname ($vg/del-$volname)\n";
-    my $cmd = ['/sbin/lvchange', '-aly', "$vg/$volname"];
+    my $cmd = ['/sbin/lvchange', '-aly', '-K', "$vg/$volname"];
     run_command($cmd, errmsg => "can't activate LV '$vg/$volname' to zero-out its data");
     $cmd = ['/sbin/lvchange', '--refresh', "$vg/$volname"];
     run_command($cmd, errmsg => "can't refresh LV '$vg/$volname' to zero-out its data");
@@ -536,7 +536,7 @@ sub activate_volume {
     my $lvm_activate_mode = 'ey';
-    my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", $path];
+    my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", '-K', $path];
     run_command($cmd, errmsg => "can't activate LV '$path'");
     $cmd = ['/sbin/lvchange', '--refresh', $path];
     run_command($cmd, errmsg => "can't refresh LV '$path' for activation");

More information about the pve-devel mailing list