mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-16 10:50:46 +03:00
add pvscan-udev-initrd.sh
pvscan wrapper for use in the initrd lvm udev rule. 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.
This commit is contained in:
parent
84607d93b6
commit
2ed8f23ae3
57
udev/pvscan-udev-initrd.sh
Normal file
57
udev/pvscan-udev-initrd.sh
Normal file
@ -0,0 +1,57 @@
|
||||
# pvscan wrapper called by initrd lvm udev rule to find the
|
||||
# intersection of complete VGs/LVs found by pvscan and the
|
||||
# requested VGs/LVs from the cmdline.
|
||||
#
|
||||
# Used in 64-lvm.rules as:
|
||||
# IMPORT{program}="pvscan-udev-initrd.sh $env{DEVNAME}"
|
||||
#
|
||||
# See /usr/lib/dracut/modules.d/90lvm/64-lvm.rules
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
dev=$1
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
|
||||
VGS=$(getargs rd.lvm.vg -d rd_LVM_VG=)
|
||||
LVS=$(getargs rd.lvm.lv -d rd_LVM_LV=)
|
||||
|
||||
IFS=' '
|
||||
|
||||
# pvscan will produce a single VG line, and one or more LV lines.
|
||||
# VG <name> complete
|
||||
# VG <name> incomplete
|
||||
# LV <name> complete
|
||||
# LV <name> incomplete
|
||||
#
|
||||
# LV names are printed as vgname/lvname.
|
||||
# We only care about the complete items.
|
||||
# Each pvscan will produce a single VG line,
|
||||
# and may produce zero, one or more LV lines.
|
||||
|
||||
PVSCAN=$(/usr/sbin/lvm pvscan --cache --listlvs --checkcomplete --journal output --config 'global/event_activation=1' $dev)
|
||||
|
||||
read -r -a VGSARRAY <<< "$VGS"
|
||||
|
||||
for VG in "${VGSARRAY[@]}"
|
||||
do
|
||||
if strstr "$PVSCAN" "VG $VG complete" ; then
|
||||
echo LVM_VG_NAME_COMPLETE=\'"$VG"\'
|
||||
fi
|
||||
done
|
||||
|
||||
# Combine all matching LVs into a single print containing them all,
|
||||
# e.g. LVM_LV_NAMES_COMPLETE='vg/lv1 vg/lv2'
|
||||
|
||||
read -r -a LVSARRAY <<< "$LVS"
|
||||
|
||||
echo -n LVM_LV_NAMES_COMPLETE=\'
|
||||
for LV in "${LVSARRAY[@]}"
|
||||
do
|
||||
if strstr "$PVSCAN" "LV $LV complete" ; then
|
||||
echo -n "$LV "
|
||||
fi
|
||||
done
|
||||
echo \'
|
||||
|
Loading…
x
Reference in New Issue
Block a user