]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
lvm: add rd_LVM_LV and "--poll n"
authorHarald Hoyer <harald@redhat.com>
Wed, 13 Jan 2010 16:59:14 +0000 (17:59 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 13 Jan 2010 16:59:14 +0000 (17:59 +0100)
dracut.8
modules.d/90lvm/lvm_scan.sh

index c75e0dde9da5213878466553e40bdd9460a1e90c..869c99970c78caabe6e5274011bce9ba205c7fbd 100644 (file)
--- a/dracut.8
+++ b/dracut.8
@@ -150,6 +150,11 @@ disable LVM detection
 .TP
 .B rd_LVM_VG=<volume group 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
 .B rd_NO_LVMCONF
 remove any /etc/lvm/lvm.conf, which may exist in the initramfs
index 3bf858a85167af1bf76b10c357ffeade38a28755..85cd78e496daa960222b58e96ea8eed1451efd8c 100755 (executable)
@@ -5,6 +5,7 @@
 . /lib/dracut-lib.sh
 
 VGS=$(getargs rd_LVM_VG=)
+LVS=$(getargs rd_LVM_LV=)
 
 [ -d /etc/lvm ] || mkdir -p /etc/lvm
 # build a list of devices to scan
@@ -31,9 +32,43 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
     } > /etc/lvm/lvm.conf
     lvmwritten=1
 fi
-info "Scanning devices $lvmdevs for LVM volume groups $VGS"
-lvm vgscan --ignorelockingfailure 2>&1 | vinfo
-lvm vgchange -ay --ignorelockingfailure --monitor n $VGS 2>&1 | vinfo
+
+check_lvm_ver() {
+    # --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
     rm -f /etc/lvm/lvm.conf
     ln -s /sbin/lvm-cleanup /pre-pivot/30-lvm-cleanup.sh 2>/dev/null