]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-function: add check for volume group members
authorHarald Hoyer <harald@redhat.com>
Mon, 31 Aug 2009 12:58:44 +0000 (14:58 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 1 Sep 2009 13:42:28 +0000 (15:42 +0200)
see https://bugzilla.redhat.com/show_bug.cgi?id=506189

not all members of a linear volume group are listed in /sys slaves

dracut-functions

index ffb03b7197a20378f41d045d82e6cb2d723c6a61..7544fc6bd05ef592582e8b989b380b4353b4d441 100755 (executable)
@@ -91,6 +91,7 @@ check_block_and_slaves() {
     local x 
     [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
     "$1" $2 && return
+    check_vol_slaves "$@" && return 0
     [[ -d /sys/dev/block/$2/slaves ]] || return 1
     for x in /sys/dev/block/$2/slaves/*/dev; do
         [[ -f $x ]] || continue
@@ -99,6 +100,35 @@ check_block_and_slaves() {
     return 1
 }
 
+get_numeric_dev() {
+    ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min;}
+}
+
+# ugly workaround for the lvm design
+# There is no volume group device,
+# so, there are no slave devices for volume groups.
+# Logical volumes only have the slave devices they really live on,
+# but you cannot create the logical volume without the volume group.
+# And the volume group might be bigger than the devices the LV needes.
+check_vol_slaves() {
+    for i in /dev/mapper/*; do 
+       lv=$(get_numeric_dev $i)
+       if [[ $lv = $2 ]]; then
+           vg=$(lvs --noheadings -o vg_name $i 2>/dev/null)
+           # strip space
+           vg=$(echo $vg)
+           if [[ $vg ]]; then
+               for pv in $(vgs --noheadings -o pv_name "$vg" 2>/dev/null); \
+                   do
+                   check_block_and_slaves $1 $(get_numeric_dev $pv) \
+                       &&  return 0
+               done
+           fi
+       fi
+    done
+    return 1
+}
+
 # $1 = file to copy to ramdisk
 # $2 (optional) Name for the file on the ramdisk
 # Location of the image dir is assumed to be $initdir