From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adolf Belka To: development@lists.ipfire.org Subject: [PATCH 1/2] lvm: Fixes bug-13151 - update 69-dm-lvm.rules Date: Sun, 18 Jun 2023 20:02:09 +0200 Message-ID: <20230618180210.3467088-1-adolf.belka@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8348913681475599542==" List-Id: --===============8348913681475599542== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable - Redhat updated lvm udev rule 69-dm-lvm.rules to only work with systemd - Update 69-dm-lvm.rules to work with IPFire based on input from @Daniel of w= hat worked to mount an existing lvm volume Suggested-by: Daniel Weism=C3=BCller Signed-off-by: Adolf Belka --- config/lvm/69-dm-lvm.rules | 83 ++++++++++++++++++++++++++++++++++++++ lfs/lvm2 | 2 + 2 files changed, 85 insertions(+) create mode 100644 config/lvm/69-dm-lvm.rules diff --git a/config/lvm/69-dm-lvm.rules b/config/lvm/69-dm-lvm.rules new file mode 100644 index 000000000..a1c6be14f --- /dev/null +++ b/config/lvm/69-dm-lvm.rules @@ -0,0 +1,83 @@ +# Copyright (C) 2012,2021 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM. +# +# This rule requires blkid to be called on block devices before so only devi= ces +# used as LVM PVs are processed (ID_FS_TYPE=3D"LVM2_member"). + +SUBSYSTEM!=3D"block", GOTO=3D"lvm_end" + + +ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=3D=3D"1", GOTO=3D"lvm_end" + +# Only process devices already marked as a PV - this requires blkid to be ca= lled before. +ENV{ID_FS_TYPE}!=3D"LVM2_member", GOTO=3D"lvm_end" +ENV{DM_MULTIPATH_DEVICE_PATH}=3D=3D"1", GOTO=3D"lvm_end" +ACTION=3D=3D"remove", GOTO=3D"lvm_end" + +# Create /dev/disk/by-id/lvm-pv-uuid- symlink for each PV +ENV{ID_FS_UUID_ENC}=3D=3D"?*", SYMLINK+=3D"disk/by-id/lvm-pv-uuid-$env{ID_FS= _UUID_ENC}" + +# If the PV is a special device listed below, scan only if the device is +# properly activated. These devices are not usable after an ADD event, +# but they require an extra setup and they are ready after a CHANGE event. +# Also support coldplugging with ADD event but only if the device is already +# properly activated. +# This logic should be eventually moved to rules where those particular +# devices are processed primarily (MD and loop). + +# DM device: +KERNEL!=3D"dm-[0-9]*", GOTO=3D"next" +ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=3D=3D"1", ENV{DM_ACTIVATION}=3D=3D"1", GOTO= =3D"lvm_scan" +GOTO=3D"lvm_end" + +# MD device: +LABEL=3D"next" +KERNEL!=3D"md[0-9]*", GOTO=3D"next" +IMPORT{db}=3D"LVM_MD_PV_ACTIVATED" +ACTION=3D=3D"add", ENV{LVM_MD_PV_ACTIVATED}=3D=3D"1", GOTO=3D"lvm_scan" +ACTION=3D=3D"change", ENV{LVM_MD_PV_ACTIVATED}!=3D"1", TEST=3D=3D"md/array_s= tate", ENV{LVM_MD_PV_ACTIVATED}=3D"1", GOTO=3D"lvm_scan" +ACTION=3D=3D"add", KERNEL=3D=3D"md[0-9]*p[0-9]*", GOTO=3D"lvm_scan" +GOTO=3D"lvm_end" + +# Loop device: +LABEL=3D"next" +KERNEL!=3D"loop[0-9]*", GOTO=3D"next" +ACTION=3D=3D"add", ENV{LVM_LOOP_PV_ACTIVATED}=3D=3D"1", GOTO=3D"lvm_scan" +ACTION=3D=3D"change", ENV{LVM_LOOP_PV_ACTIVATED}!=3D"1", TEST=3D=3D"loop/bac= king_file", ENV{LVM_LOOP_PV_ACTIVATED}=3D"1", GOTO=3D"lvm_scan" +GOTO=3D"lvm_end" + +LABEL=3D"next" +ACTION!=3D"add", GOTO=3D"lvm_end" + +LABEL=3D"lvm_scan" + +# pvscan will check if this device completes a VG, +# i.e. all PVs in the VG are now present with the +# arrival of this PV. If so, it prints to stdout: +# LVM_VG_NAME_COMPLETE=3D'foo' +# +# When the VG is complete it can be activated, so +# vgchange -aay is run. It is run via +# systemd since it can take longer to run than +# udev wants to block when processing rules. +# (if there are hundreds of LVs to activate, +# the vgchange can take many seconds.) +# +# pvscan only reads the single device specified, +# and uses temp files under /run/lvm to check if +# other PVs in the VG are present. +# +# If event_activation=3D0 in lvm.conf, this pvscan +# (using checkcomplete) will do nothing, so that +# no event-based autoactivation will be happen. +# +# TODO: adjust the output of vgchange -aay so that +# it's better suited to appearing in the journal. + +IMPORT{program}=3D"/usr/sbin/lvm pvscan --cache --listvg --checkcomplete --v= gonline --autoactivation event --udevoutput --journal=3Doutput $env{DEVNAME}" +ENV{LVM_VG_NAME_COMPLETE}=3D=3D"?*", RUN+=3D"/usr/sbin/lvm vgchange -aay --a= utoactivation event $env{LVM_VG_NAME_COMPLETE}" +GOTO=3D"lvm_end" + +LABEL=3D"lvm_end" + diff --git a/lfs/lvm2 b/lfs/lvm2 index 2f1e921fc..4e2bd6235 100644 --- a/lfs/lvm2 +++ b/lfs/lvm2 @@ -85,5 +85,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) --enable-udev_sync cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install + # copy the tailored lvm udev rules file that will mount volumes without sys= temd + cp -rf $(DIR_SRC)/config/lvm/69-dm-lvm.rules /lib/udev/rules.d/ @rm -rf $(DIR_APP) @$(POSTBUILD) --=20 2.41.0 --===============8348913681475599542==--