Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/initramfs: use LVM autoactivation for activating VGs #17125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frwbr
Copy link

@frwbr frwbr commented Mar 7, 2025

Motivation and Context

Currently, when zfs-initramfs is installed on a host, all LVM LVs will be activated on boot, regardless of the respective VG/LV autoactivation settings such as --setautoactivation n on an LV. The reason is that a boot script shipped by zfs-initramfs calls vgchange -ay, which unconditionally activates all LVs. This patch changes the call to vgchange -aay, which honors autoactivation settings.

For context: We encountered this on Proxmox VE (a Debian derivative shipping ZFS focused on virtualization), where it is not uncommon to e.g. boot from ZFS but have additional LVM VGs on external storage, e.g. on a LUN provided by a SAN and accessed via iSCSI/Fibre Channel. We were looking into disabling autoactivation in order to fix a bug, and wondered why --setautoactivation n did not appear to have an effect on VGs that are already visible at boot. If you're interested, you can find more details in this patch series.

Description

See also the commit message.

One way to reproduce:

  • install Ubuntu, e.g. from Ubuntu 24.10 cloudimg
  • create LVM PV on extra disk, VG+LV with autoactivation disabled:
# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
# vgcreate testvg /dev/sdb
  Volume group "testvg" successfully created
# lvcreate testvg --name testlv --size 500M --setautoactivation n
  Logical volume "testlv" created.
  • reboot
  • LV testvg/testlv is not active (look for the a flag):
# lvs
  LV     VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi------- 500.00m
  • apt install zfsutils-linux zfs-initramfs
  • reboot
  • LV testvg/testlv is active:
# lvs
  LV     VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  testlv testvg -wi-a----- 500.00m

How Has This Been Tested?

Ater running the reproducer above, I applied this patch manually to /usr/share/initramfs-tools/scripts/local-top/zfs, updated initramfs, rebooted, and verified that LV testvg/testlv is not active.

Types of changes

Checking "breaking change" here, as it is technically one on setups which can be considered misconfigured, see the commit message.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

I believe the unchecked boxes do not apply here though I'm not 100% sure -- if they do, please let me know. :)

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 <[email protected]>
Reviewed-by: Fabian Grünbichler <[email protected]>
@frwbr frwbr force-pushed the initramfs-lvm-autoactivation branch from 3726c50 to 693ab2e Compare March 7, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant