Browse Source

lvm: add rd_LVM_LV and "--poll n"

master
Harald Hoyer 15 years ago
parent
commit
dc0a0f6c93
  1. 5
      dracut.8
  2. 41
      modules.d/90lvm/lvm_scan.sh

5
dracut.8

@ -150,6 +150,11 @@ disable LVM detection
.TP .TP
.B rd_LVM_VG=<volume group name> .B rd_LVM_VG=<volume group name>
only activate the volume groups with the given name only activate the volume groups with the given name
rd_LVM_VG can be specified multiple times on the kernel command line.
.TP
.B rd_LVM_LV=<logical volume name>
only activate the volume groups with the given name
rd_LVM_LV can be specified multiple times on the kernel command line.
.TP .TP
.B rd_NO_LVMCONF .B rd_NO_LVMCONF
remove any /etc/lvm/lvm.conf, which may exist in the initramfs remove any /etc/lvm/lvm.conf, which may exist in the initramfs

41
modules.d/90lvm/lvm_scan.sh

@ -5,6 +5,7 @@
. /lib/dracut-lib.sh . /lib/dracut-lib.sh


VGS=$(getargs rd_LVM_VG=) VGS=$(getargs rd_LVM_VG=)
LVS=$(getargs rd_LVM_LV=)


[ -d /etc/lvm ] || mkdir -p /etc/lvm [ -d /etc/lvm ] || mkdir -p /etc/lvm
# build a list of devices to scan # build a list of devices to scan
@ -31,9 +32,43 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
} > /etc/lvm/lvm.conf } > /etc/lvm/lvm.conf
lvmwritten=1 lvmwritten=1
fi fi
info "Scanning devices $lvmdevs for LVM volume groups $VGS"
lvm vgscan --ignorelockingfailure 2>&1 | vinfo check_lvm_ver() {
lvm vgchange -ay --ignorelockingfailure --monitor n $VGS 2>&1 | vinfo # --poll is supported since 2.2.57
[ $1 -lt 2 ] && return 1
[ $1 -gt 2 ] && return 0
# major is 2
[ $2 -lt 2 ] && return 1
[ $2 -gt 2 ] && return 0
# minor is 2, check for
# greater or equal 57
[ $3 -ge 57 ] && return 0
return 1
}

nopoll=$(
# hopefully this output format will never change, e.g.:
# LVM version: 2.02.53(1) (2009-09-25)
lvm version 2>/dev/null | \
(
IFS=. read maj min sub;
maj=${maj##*:};
sub=${sub%% *}; sub=${sub%%\(*};
check_lvm_ver $maj $min $sub && \
echo " --poll n "))

if [ -n "$LVS" ] ; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
lvm lvscan --ignorelockingfailure 2>&1 | vinfo
lvm lvchange -ay --ignorelockingfailure $nopoll --monitor n $LVS 2>&1 | vinfo
fi

if [ -z "$LVS" -o -n "$VGS" ]; then
info "Scanning devices $lvmdevs for LVM volume groups $VGS"
lvm vgscan --ignorelockingfailure 2>&1 | vinfo
lvm vgchange -ay --ignorelockingfailure $nopoll --monitor n $VGS 2>&1 | vinfo
fi

if [ "$lvmwritten" ]; then if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf rm -f /etc/lvm/lvm.conf
ln -s /sbin/lvm-cleanup /pre-pivot/30-lvm-cleanup.sh 2>/dev/null ln -s /sbin/lvm-cleanup /pre-pivot/30-lvm-cleanup.sh 2>/dev/null

Loading…
Cancel
Save