From ee73875ff0e2e4f93d2acf75e7ec33b216f84c97 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Thu, 8 Feb 2024 14:51:46 -0600 Subject: [PATCH] udev: ignore LVs containing PVs If LVM LVs happen to contain PVs, they are passed to the lvm udev rule for processing, where they should be ignored. PVs on LVs most likely belong to VM images, and don't belong to the host which sees the LV. It's unsafe for the host to use these PVs. Without this change, the LV would be processed by pvscan which would generally ignore it, either because of the devices file, or because of the default lvm policy to not consider LVs as potential PVs. This change makes the udev rule consistent with that policy and avoids the unnecessary system messages produced when pvscan ignores the LV. --- udev/69-dm-lvm.rules.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/udev/69-dm-lvm.rules.in b/udev/69-dm-lvm.rules.in index ff1568145..f7a6eef8f 100644 --- a/udev/69-dm-lvm.rules.in +++ b/udev/69-dm-lvm.rules.in @@ -10,6 +10,15 @@ SUBSYSTEM!="block", GOTO="lvm_end" ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end" +# Ignore PVs on LVs. +# This is usually a case of an LV being used for a guest VM +# image, where the guest is using lvm. The host should +# ignore lvm data from the guest and not attempt to scan or +# activate guest PVs/LVs. (To enable functions in this file +# for PVs layered on LVs, set LVM_PVSCAN_ON_LVS="1" from a +# custom udev rule.) +ENV{ID_FS_TYPE}=="LVM2_member", ENV{DM_UUID}=="LVM-?*", ENV{LVM_PVSCAN_ON_LVS}!="1", GOTO="lvm_end" + # Only process devices already marked as a PV - this requires blkid to be called before. ENV{ID_FS_TYPE}!="LVM2_member", GOTO="lvm_end" ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end"