From 533d7dc4ab642008a53c7bd681724ffcbd426426 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 31 Aug 2009 14:58:44 +0200 Subject: [PATCH] dracut-function: add check for volume group members 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 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dracut-functions b/dracut-functions index ffb03b7..7544fc6 100755 --- a/dracut-functions +++ b/dracut-functions @@ -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 -- 2.7.4