1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-21 22:04:19 +03:00
lvm2/dracut/64-lvm.rules
David Teigland c229e321da add dracut files
pvscan-udev-initrd.sh is shell wrapper around the
pvscan command for use in the initrd lvm udev rule.
It finds the intersection of complete VG/LVs reported
by pvscan, and the VG/LVs specified on boot cmdline.
The resulting VG or LVs are printed as env-vars that
the udev rule can IMPORT, and pass to vgchange/lvchange.

64-lvm.rules calls pvscan-udev-initrd.sh/pvscan to scan
the PV to check if any VG or LVs are complete given the
new device.  The pvscan will only ever read the single
device triggering the uevent.  If any VG or LVs are
complete, the udev rule uses systemd-run to run a
vgchange or lvchange command to activate the complete
VG or LVs.  (Running vgchange or lvchange directly may
take longer than udev likes, so systemd-run --no-block
is used.)
2021-07-14 12:52:22 -05:00

45 lines
1.8 KiB
Plaintext

# Copyright 2008,2021 Red Hat, Inc.
#
# Jeremy Katz <katzj@redhat.com>
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", ACTION=="add", GOTO="lvm_end"
ENV{ID_FS_TYPE}!="LVM2_member", GOTO="lvm_end"
PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/dm-[0-9]*; do [ -e $$i ] && exit 0; done; exit 1;' ", \
GOTO="lvm_end"
# pvscan-udev-initrd.sh is a wrapper that calls pvscan and prints
# LVM_VG_NAME_COMPLETE='...'
# LVM_LV_NAMES_COMPLETE='...'
# if the given device completes a VG or LVs listed in
# rd.lvm.vg or rd.lvm.lv
#
# If a VG or LVs are completed by the device, but are not
# listed in rd.lvm.vg/lv, then they are not printed
# (we don't want to activate VGs/LVs that are not specified.)
#
# If no VG or LVs are completed by the device, then
# nothing is printed.
#
# LVs may be complete and activated before the VG is complete,
# i.e. the entire VG is not necessary to activate LVs in it.
#
# If multiple LV names are completed from one device,
# e.g. LVM_LV_NAMES_COMPLETE='vg/lv1 vg/lv2 vg/lv3'
# they will be activated by one lvchange command.
IMPORT{program}="pvscan-udev-initrd.sh $env{DEVNAME}"
# systemd services are used to run vgchange/lvchange
# because the lvm activation commands can run for longer
# than udev will tolerate.
ENV{LVM_VG_NAME_COMPLETE}=="?*", RUN+="/usr/bin/systemd-run --no-block --property DefaultDependencies=no /sbin/lvm vgchange -ay --yes --ignoremonitoring --poll n --sysinit $env{LVM_VG_NAME_COMPLETE}"
ENV{LVM_LV_NAMES_COMPLETE}=="?*", RUN+="/usr/bin/systemd-run --no-block --property DefaultDependencies=no /sbin/lvm lvchange -ay --yes -K --ignoremonitoring --poll n --sysinit $env{LVM_LV_NAMES_COMPLETE}"
LABEL="lvm_end"