zfs-initramfs ships an initramfs-tools boot script that
unconditionally activates all LVs on boot. This can cause issues if
the LV resides on a shared LVM VG on top of a shared LUN, in
particular Fibre Channel / directed-attached SAS LUNs, as these are
usually visible at boot time. See bug #4997 [1] for more details.

To avoid this, patch zfs-initramfs such that it performs LVM
autoactivation instead. Thus, it honors the `--setautoactivation n`
flag that is normally used to disable autoactivation during boot for
particular VGs/LVs.

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

Signed-off-by: Friedrich Weber <f.we...@proxmox.com>
---

Notes:
    new in v2
    
    I'm also planning on sending the inner patch upstream, well post here
    once I do.

 ...s-use-LVM-autoactivation-for-activat.patch | 49 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 50 insertions(+)
 create mode 100644 
debian/patches/0012-contrib-initramfs-use-LVM-autoactivation-for-activat.patch

diff --git 
a/debian/patches/0012-contrib-initramfs-use-LVM-autoactivation-for-activat.patch
 
b/debian/patches/0012-contrib-initramfs-use-LVM-autoactivation-for-activat.patch
new file mode 100644
index 0000000..e51096d
--- /dev/null
+++ 
b/debian/patches/0012-contrib-initramfs-use-LVM-autoactivation-for-activat.patch
@@ -0,0 +1,49 @@
+From 3726c500deffadce1012b5c5ccf19515bb58bdbb Mon Sep 17 00:00:00 2001
+From: Friedrich Weber <f.we...@proxmox.com>
+Date: Thu, 6 Mar 2025 11:44:36 +0100
+Subject: [PATCH] contrib/initramfs: use LVM autoactivation for activating VGs
+
+Currently, the zfs initramfs-tools boot script under local-top calls
+`vgchange -ay`, which unconditionally activates all logical volumes
+(LVs) in all discovered volume groups (VGs). This causes all LVs to be
+active after boot. However, users may prefer to not activate certain
+VGs/LVs on boot. They might normally use the `--setautoactivation n`
+VG/LV flag or the `auto_activation_volume_list` LVM config option to
+achieve this, but since the script unconditionally activates all LVs,
+neither has an effect.
+
+To fix this, call `vgchange -aay` instead. This triggers LVM
+autoactivation, which honors autoactivation settings such as the
+`--setautoactivation` flag. It is also more in line with the LVM
+documentation, which says autoactivation is "meant to be used by
+activation commands that are run automatically by the system" [1].
+
+Note that this change might break misconfigured setups that have ZFS
+on top of an LV for which autoactivation is disabled.
+
+[1] https://gitlab.com/lvmteam/lvm2/-/blob/cff93e4d/conf/example.conf.in#L1579
+
+Signed-off-by: Friedrich Weber <f.we...@proxmox.com>
+---
+ contrib/initramfs/scripts/local-top/zfs | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/contrib/initramfs/scripts/local-top/zfs 
b/contrib/initramfs/scripts/local-top/zfs
+index 6b80e9f43..fc455077e 100755
+--- a/contrib/initramfs/scripts/local-top/zfs
++++ b/contrib/initramfs/scripts/local-top/zfs
+@@ -41,9 +41,9 @@ activate_vg()
+                 return 1
+         fi
+ 
+-        # Detect and activate available volume groups
++        # Detect and auto-activate available volume groups
+         /sbin/lvm vgscan
+-        /sbin/lvm vgchange -a y --sysinit
++        /sbin/lvm vgchange -aay --sysinit
+         return $?
+ }
+ 
+-- 
+2.39.5
+
diff --git a/debian/patches/series b/debian/patches/series
index 229027f..71e830f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@
 0009-arc-stat-summary-guard-access-to-freshly-introduced-.patch
 0010-Fix-nfs_truncate_shares-without-etc-exports.d.patch
 0011-zpool-status-tighten-bounds-for-noalloc-stat-availab.patch
+0012-contrib-initramfs-use-LVM-autoactivation-for-activat.patch
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to