From b593e3099a7cb1b2684211aee314c52d5cb8201eeaaae2e270ace573dcc453e4 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 15 Jan 2010 16:44:42 +0000 Subject: [PATCH 1/3] Accepting request 29763 from home:michal-m:branches:Base:System Copy from home:michal-m:branches:Base:System/mdadm via accept of submit request 29763 revision 2. Request was accepted with message: Reviewed ok OBS-URL: https://build.opensuse.org/request/show/29763 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=12 --- boot.md | 10 ++++++- mdadm.changes | 12 +++++++++ mdadm.spec | 16 +++++++++-- mkinitrd-boot.sh | 19 +++++++++++-- mkinitrd-setup.sh | 69 ++++++++++++++++++++--------------------------- 5 files changed, 81 insertions(+), 45 deletions(-) diff --git a/boot.md b/boot.md index 946b67d..5e201e5 100644 --- a/boot.md +++ b/boot.md @@ -98,6 +98,14 @@ case "$1" in start) echo -n "Starting MD Raid " + # create the /var/run/mdadm symlink if needed + mkdir -p /dev/.mdadm + if test ! /dev/.mdadm -ef /var/run/mdadm; then + rm -rf /var/run/mdadm + ln -s /dev/.mdadm /var/run/mdadm + fi + # restart mdmon (exits silently if there is nothing to monitor) + /sbin/mdmon /proc/mdstat / # Check for existence of needed config file and read it [ -r $mdadm_SYSCONFIG ] || _rc_exit 6 "... $mdadm_SYSCONFIG not existing " @@ -110,7 +118,7 @@ case "$1" in [ -x $mdadm_BIN ] || _rc_exit 5 "... $mdadm_BIN not installed " # Try to load md_mod - [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe -k md_mod 2>&1 | : + [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe md_mod [ -f /proc/mdstat ] || _rc_exit 5 "... no MD support in kernel " # Wait for udev to settle diff --git a/mdadm.changes b/mdadm.changes index 8cf1029..322d019 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri Jan 15 17:37:26 CET 2010 - mmarek@suse.cz + +- fix modprobe invocation in boot.md (bnc#565293). + +------------------------------------------------------------------- +Fri Jan 15 17:04:06 CET 2010 - mmarek@suse.cz + +- store mdmon runtime files in /dev/.mdadm, to make it easier to + transfer mdmon from the initrd to the real root. +- rework the mkinitrd setup script a bit. + ------------------------------------------------------------------- Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index 1d63461..0d633c2 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -70,13 +70,25 @@ install -m 755 %{S:5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/setup-md.sh install -m 755 %{S:6} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-md.sh install -m 644 %{S:2} $RPM_BUILD_ROOT%{_var}/adm/fillup-templates/ ln -sf ../../etc/init.d/mdadmd $RPM_BUILD_ROOT/%{_sbindir}/rcmdadmd -install -d $RPM_BUILD_ROOT/var/run/mdadm +rm -rf $RPM_BUILD_ROOT/var/run/mdadm +mkdir -p $RPM_BUILD_ROOT/var/run +ln -s mdadm $RPM_BUILD_ROOT/var/run/mdadm # remove here, using the one in the udev package rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/64-md-raid.rules %post [ -x /sbin/mkinitrd_setup ] && mkinitrd_setup %{fillup_and_insserv -y boot.md} +mkdir -p /dev/.mdadm +# replace the /var/run/mdadm directory (installed by sle11/11.1) with +# a symlink pointing to /dev/.mdadm. Do not do this when /var/run/mdadm is +# not empty, let /etc/init.d/boot.md do it at the next reboot. +if test -e /var/run/mdadm -a ! /var/run/mdadm -ef /dev/.mdadm; then + if ! rmdir /var/run/mdadm 2>/dev/null; then + exit 0 + fi + ln -s /dev/.mdadm /var/run/mdadm +fi %postun %restart_on_update mdadmd @@ -100,7 +112,7 @@ rm -rf $RPM_BUILD_ROOT %dir /lib/udev/devices %{_sbindir}/* %{_var}/adm/fillup-templates/sysconfig.mdadm -%dir /var/run/mdadm +%ghost /var/run/mdadm %dir /lib/mkinitrd %dir /lib/mkinitrd/scripts /lib/mkinitrd/scripts/setup-md.sh diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index a7f54cd..a5c7019 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -18,6 +18,11 @@ # load the necessary module before we initialize the raid system load_modules +# put the mdmon socked and pid file to /dev/.mdadm +rm -rf /var/run/mdadm +mkdir -p /var/run +ln -s /dev/.mdadm /var/run/mdadm +mkdir -p /dev/.mdadm [ "$mduuid" ] && md_uuid="$mduuid" md_major=$(sed -ne 's/\s*\([0-9]\+\)\s*md$/\1/p' /proc/devices) @@ -49,9 +54,19 @@ md_assemble() else mdconf="-c partitions" fi - if test -n "$container"; then + case "$container" in + "") + ;; + /dev/*) + mdadm -A $mdconf $container + ;; + [0-9a-f]*[0-9a-f]) mdadm -A $mdconf --uuid="$container" /dev/md/container - fi + ;; + *) + echo "unrecognized container for $dev: $container" + ;; + esac mdadm -A $mdconf $mdarg "$dev" } diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 52c1cb7..750508c 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -12,7 +12,6 @@ cont_list= md_devs= # blockdev contains real devices (/dev/X) for root, resume, journal, dumb -echo "blockdev: $blockdev" for bd in $blockdev ; do is_part_dev=false case $bd in @@ -43,46 +42,36 @@ for bd in $blockdev ; do fi continue fi - # Get UUID of block device - tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) - if [ -n "$tmp_uuid" ]; then - md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") - uuid=${tmp_uuid##MD_} - # Get the corresponding line from config - arr_line=$(echo "$mdadm_conf" | grep "$uuid") - if test -z "$arr_line"; then - continue - fi - # Check for container - cont_line= - cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") - if [ -n "$cont" ]; then - cnt_dup=0 - for cnt in $cont_list; do - if [ x"$cont"= x"$cnt" ]; then - cnt_dup=1 - fi - done - if [ $cnt_dup -eq 0 ]; then - cont_list="$cont_list $cont" - cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") - cont_line="$cont_line\n" - fi - fi - # add a line with the "real" md device name so that boot-md.sh finds it - cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') - real_dev=$(readlink -f "$cfg_dev") - if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then - arr_line="$arr_line$(echo -e "\\n$arr_line" | \ - sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" - fi - mdblockdev="$mdblockdev $md_tmpblockdev" - # Add ARRAY line (with container line before if needed). - cfg_line=$(echo -e "$cont_line$arr_line") - eval md_conf_${md_dev}=\""$cfg_line"\" - md_devs="$md_devs $md_dev" - root_md=1 + mdconf=$(mdadm -Db "$bd") + if test -z "$mdconf"; then + mdblockdev="$mdblockdev $bd" + continue fi + md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p") + mdblockdev="$mdblockdev $md_tmpblockdev" + md_devs="$md_devs $md_dev" + container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p') + for cnt in $cont_list; do + if [ x"$container"= x"$cnt" ]; then + container= + break + fi + done + case "$container" in + "") + ;; + /dev/*) + mdconf="$(mdadm -Db "$container")\\n$mdconf" + ;; + [0-9a-f]*[0-9a-f]) + mdconf="$(mdadm -Ebs | grep "UUID=$container")\\n$mdconf" + ;; + *) + echo "unrecognized container for $md_dev: $container" + ;; + esac + eval md_conf_${md_dev}=\"$mdconf\" + root_md=1 done # Any 'md' device is replaced by it's component disks. From 410dbf2ce6c95fe8bc64626cb372e850fac861abfb30bd5b2d41e4a540dcd403 Mon Sep 17 00:00:00 2001 From: OBS User autobuild Date: Mon, 18 Jan 2010 13:08:57 +0000 Subject: [PATCH 2/3] checked in (request 29764) OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=13 --- boot.md | 10 +------ mdadm.changes | 12 --------- mdadm.spec | 16 ++--------- mkinitrd-boot.sh | 19 ++----------- mkinitrd-setup.sh | 69 +++++++++++++++++++++++++++-------------------- 5 files changed, 45 insertions(+), 81 deletions(-) diff --git a/boot.md b/boot.md index 5e201e5..946b67d 100644 --- a/boot.md +++ b/boot.md @@ -98,14 +98,6 @@ case "$1" in start) echo -n "Starting MD Raid " - # create the /var/run/mdadm symlink if needed - mkdir -p /dev/.mdadm - if test ! /dev/.mdadm -ef /var/run/mdadm; then - rm -rf /var/run/mdadm - ln -s /dev/.mdadm /var/run/mdadm - fi - # restart mdmon (exits silently if there is nothing to monitor) - /sbin/mdmon /proc/mdstat / # Check for existence of needed config file and read it [ -r $mdadm_SYSCONFIG ] || _rc_exit 6 "... $mdadm_SYSCONFIG not existing " @@ -118,7 +110,7 @@ case "$1" in [ -x $mdadm_BIN ] || _rc_exit 5 "... $mdadm_BIN not installed " # Try to load md_mod - [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe md_mod + [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe -k md_mod 2>&1 | : [ -f /proc/mdstat ] || _rc_exit 5 "... no MD support in kernel " # Wait for udev to settle diff --git a/mdadm.changes b/mdadm.changes index 322d019..8cf1029 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,15 +1,3 @@ -------------------------------------------------------------------- -Fri Jan 15 17:37:26 CET 2010 - mmarek@suse.cz - -- fix modprobe invocation in boot.md (bnc#565293). - -------------------------------------------------------------------- -Fri Jan 15 17:04:06 CET 2010 - mmarek@suse.cz - -- store mdmon runtime files in /dev/.mdadm, to make it easier to - transfer mdmon from the initrd to the real root. -- rework the mkinitrd setup script a bit. - ------------------------------------------------------------------- Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index 0d633c2..1d63461 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -70,25 +70,13 @@ install -m 755 %{S:5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/setup-md.sh install -m 755 %{S:6} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-md.sh install -m 644 %{S:2} $RPM_BUILD_ROOT%{_var}/adm/fillup-templates/ ln -sf ../../etc/init.d/mdadmd $RPM_BUILD_ROOT/%{_sbindir}/rcmdadmd -rm -rf $RPM_BUILD_ROOT/var/run/mdadm -mkdir -p $RPM_BUILD_ROOT/var/run -ln -s mdadm $RPM_BUILD_ROOT/var/run/mdadm +install -d $RPM_BUILD_ROOT/var/run/mdadm # remove here, using the one in the udev package rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/64-md-raid.rules %post [ -x /sbin/mkinitrd_setup ] && mkinitrd_setup %{fillup_and_insserv -y boot.md} -mkdir -p /dev/.mdadm -# replace the /var/run/mdadm directory (installed by sle11/11.1) with -# a symlink pointing to /dev/.mdadm. Do not do this when /var/run/mdadm is -# not empty, let /etc/init.d/boot.md do it at the next reboot. -if test -e /var/run/mdadm -a ! /var/run/mdadm -ef /dev/.mdadm; then - if ! rmdir /var/run/mdadm 2>/dev/null; then - exit 0 - fi - ln -s /dev/.mdadm /var/run/mdadm -fi %postun %restart_on_update mdadmd @@ -112,7 +100,7 @@ rm -rf $RPM_BUILD_ROOT %dir /lib/udev/devices %{_sbindir}/* %{_var}/adm/fillup-templates/sysconfig.mdadm -%ghost /var/run/mdadm +%dir /var/run/mdadm %dir /lib/mkinitrd %dir /lib/mkinitrd/scripts /lib/mkinitrd/scripts/setup-md.sh diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index a5c7019..a7f54cd 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -18,11 +18,6 @@ # load the necessary module before we initialize the raid system load_modules -# put the mdmon socked and pid file to /dev/.mdadm -rm -rf /var/run/mdadm -mkdir -p /var/run -ln -s /dev/.mdadm /var/run/mdadm -mkdir -p /dev/.mdadm [ "$mduuid" ] && md_uuid="$mduuid" md_major=$(sed -ne 's/\s*\([0-9]\+\)\s*md$/\1/p' /proc/devices) @@ -54,19 +49,9 @@ md_assemble() else mdconf="-c partitions" fi - case "$container" in - "") - ;; - /dev/*) - mdadm -A $mdconf $container - ;; - [0-9a-f]*[0-9a-f]) + if test -n "$container"; then mdadm -A $mdconf --uuid="$container" /dev/md/container - ;; - *) - echo "unrecognized container for $dev: $container" - ;; - esac + fi mdadm -A $mdconf $mdarg "$dev" } diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 750508c..52c1cb7 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -12,6 +12,7 @@ cont_list= md_devs= # blockdev contains real devices (/dev/X) for root, resume, journal, dumb +echo "blockdev: $blockdev" for bd in $blockdev ; do is_part_dev=false case $bd in @@ -42,36 +43,46 @@ for bd in $blockdev ; do fi continue fi - mdconf=$(mdadm -Db "$bd") - if test -z "$mdconf"; then - mdblockdev="$mdblockdev $bd" - continue + # Get UUID of block device + tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) + if [ -n "$tmp_uuid" ]; then + md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") + uuid=${tmp_uuid##MD_} + # Get the corresponding line from config + arr_line=$(echo "$mdadm_conf" | grep "$uuid") + if test -z "$arr_line"; then + continue + fi + # Check for container + cont_line= + cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") + if [ -n "$cont" ]; then + cnt_dup=0 + for cnt in $cont_list; do + if [ x"$cont"= x"$cnt" ]; then + cnt_dup=1 + fi + done + if [ $cnt_dup -eq 0 ]; then + cont_list="$cont_list $cont" + cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") + cont_line="$cont_line\n" + fi + fi + # add a line with the "real" md device name so that boot-md.sh finds it + cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') + real_dev=$(readlink -f "$cfg_dev") + if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then + arr_line="$arr_line$(echo -e "\\n$arr_line" | \ + sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" + fi + mdblockdev="$mdblockdev $md_tmpblockdev" + # Add ARRAY line (with container line before if needed). + cfg_line=$(echo -e "$cont_line$arr_line") + eval md_conf_${md_dev}=\""$cfg_line"\" + md_devs="$md_devs $md_dev" + root_md=1 fi - md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p") - mdblockdev="$mdblockdev $md_tmpblockdev" - md_devs="$md_devs $md_dev" - container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p') - for cnt in $cont_list; do - if [ x"$container"= x"$cnt" ]; then - container= - break - fi - done - case "$container" in - "") - ;; - /dev/*) - mdconf="$(mdadm -Db "$container")\\n$mdconf" - ;; - [0-9a-f]*[0-9a-f]) - mdconf="$(mdadm -Ebs | grep "UUID=$container")\\n$mdconf" - ;; - *) - echo "unrecognized container for $md_dev: $container" - ;; - esac - eval md_conf_${md_dev}=\"$mdconf\" - root_md=1 done # Any 'md' device is replaced by it's component disks. From 298bcd22f85bfb03e7d0b3f05a96f4488f33b73c7d8402ca53c73151ae7558ba Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Mon, 18 Jan 2010 13:08:58 +0000 Subject: [PATCH 3/3] Updating link to change in openSUSE:Factory/mdadm revision 37.0 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=9b73d48c6d474dda681e03d96abdf80c --- boot.md | 10 ++++++- mdadm.changes | 12 +++++++++ mdadm.spec | 18 ++++++++++--- mkinitrd-boot.sh | 19 +++++++++++-- mkinitrd-setup.sh | 69 ++++++++++++++++++++--------------------------- 5 files changed, 82 insertions(+), 46 deletions(-) diff --git a/boot.md b/boot.md index 946b67d..5e201e5 100644 --- a/boot.md +++ b/boot.md @@ -98,6 +98,14 @@ case "$1" in start) echo -n "Starting MD Raid " + # create the /var/run/mdadm symlink if needed + mkdir -p /dev/.mdadm + if test ! /dev/.mdadm -ef /var/run/mdadm; then + rm -rf /var/run/mdadm + ln -s /dev/.mdadm /var/run/mdadm + fi + # restart mdmon (exits silently if there is nothing to monitor) + /sbin/mdmon /proc/mdstat / # Check for existence of needed config file and read it [ -r $mdadm_SYSCONFIG ] || _rc_exit 6 "... $mdadm_SYSCONFIG not existing " @@ -110,7 +118,7 @@ case "$1" in [ -x $mdadm_BIN ] || _rc_exit 5 "... $mdadm_BIN not installed " # Try to load md_mod - [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe -k md_mod 2>&1 | : + [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe md_mod [ -f /proc/mdstat ] || _rc_exit 5 "... no MD support in kernel " # Wait for udev to settle diff --git a/mdadm.changes b/mdadm.changes index 8cf1029..322d019 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri Jan 15 17:37:26 CET 2010 - mmarek@suse.cz + +- fix modprobe invocation in boot.md (bnc#565293). + +------------------------------------------------------------------- +Fri Jan 15 17:04:06 CET 2010 - mmarek@suse.cz + +- store mdmon runtime files in /dev/.mdadm, to make it easier to + transfer mdmon from the initrd to the real root. +- rework the mkinitrd setup script a bit. + ------------------------------------------------------------------- Wed Jan 6 15:47:03 CET 2010 - mmarek@suse.cz diff --git a/mdadm.spec b/mdadm.spec index 1d63461..4f7ef6f 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -20,7 +20,7 @@ Name: mdadm Version: 3.0.3 -Release: 1 +Release: 2 BuildRequires: sgmltool PreReq: %fillup_prereq %insserv_prereq Obsoletes: raidtools @@ -70,13 +70,25 @@ install -m 755 %{S:5} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/setup-md.sh install -m 755 %{S:6} $RPM_BUILD_ROOT/lib/mkinitrd/scripts/boot-md.sh install -m 644 %{S:2} $RPM_BUILD_ROOT%{_var}/adm/fillup-templates/ ln -sf ../../etc/init.d/mdadmd $RPM_BUILD_ROOT/%{_sbindir}/rcmdadmd -install -d $RPM_BUILD_ROOT/var/run/mdadm +rm -rf $RPM_BUILD_ROOT/var/run/mdadm +mkdir -p $RPM_BUILD_ROOT/var/run +ln -s mdadm $RPM_BUILD_ROOT/var/run/mdadm # remove here, using the one in the udev package rm -f $RPM_BUILD_ROOT/lib/udev/rules.d/64-md-raid.rules %post [ -x /sbin/mkinitrd_setup ] && mkinitrd_setup %{fillup_and_insserv -y boot.md} +mkdir -p /dev/.mdadm +# replace the /var/run/mdadm directory (installed by sle11/11.1) with +# a symlink pointing to /dev/.mdadm. Do not do this when /var/run/mdadm is +# not empty, let /etc/init.d/boot.md do it at the next reboot. +if test -e /var/run/mdadm -a ! /var/run/mdadm -ef /dev/.mdadm; then + if ! rmdir /var/run/mdadm 2>/dev/null; then + exit 0 + fi + ln -s /dev/.mdadm /var/run/mdadm +fi %postun %restart_on_update mdadmd @@ -100,7 +112,7 @@ rm -rf $RPM_BUILD_ROOT %dir /lib/udev/devices %{_sbindir}/* %{_var}/adm/fillup-templates/sysconfig.mdadm -%dir /var/run/mdadm +%ghost /var/run/mdadm %dir /lib/mkinitrd %dir /lib/mkinitrd/scripts /lib/mkinitrd/scripts/setup-md.sh diff --git a/mkinitrd-boot.sh b/mkinitrd-boot.sh index a7f54cd..a5c7019 100644 --- a/mkinitrd-boot.sh +++ b/mkinitrd-boot.sh @@ -18,6 +18,11 @@ # load the necessary module before we initialize the raid system load_modules +# put the mdmon socked and pid file to /dev/.mdadm +rm -rf /var/run/mdadm +mkdir -p /var/run +ln -s /dev/.mdadm /var/run/mdadm +mkdir -p /dev/.mdadm [ "$mduuid" ] && md_uuid="$mduuid" md_major=$(sed -ne 's/\s*\([0-9]\+\)\s*md$/\1/p' /proc/devices) @@ -49,9 +54,19 @@ md_assemble() else mdconf="-c partitions" fi - if test -n "$container"; then + case "$container" in + "") + ;; + /dev/*) + mdadm -A $mdconf $container + ;; + [0-9a-f]*[0-9a-f]) mdadm -A $mdconf --uuid="$container" /dev/md/container - fi + ;; + *) + echo "unrecognized container for $dev: $container" + ;; + esac mdadm -A $mdconf $mdarg "$dev" } diff --git a/mkinitrd-setup.sh b/mkinitrd-setup.sh index 52c1cb7..750508c 100644 --- a/mkinitrd-setup.sh +++ b/mkinitrd-setup.sh @@ -12,7 +12,6 @@ cont_list= md_devs= # blockdev contains real devices (/dev/X) for root, resume, journal, dumb -echo "blockdev: $blockdev" for bd in $blockdev ; do is_part_dev=false case $bd in @@ -43,46 +42,36 @@ for bd in $blockdev ; do fi continue fi - # Get UUID of block device - tmp_uuid=$(mdadm -D $bd --export 2>/dev/null | grep UUID=) - if [ -n "$tmp_uuid" ]; then - md_tmpblockdev=$(mdadm -Dbv $bd 2> /dev/null | sed -n "1D;s/,/ /g;s/^ *devices=\(.*\)/\1/p") - uuid=${tmp_uuid##MD_} - # Get the corresponding line from config - arr_line=$(echo "$mdadm_conf" | grep "$uuid") - if test -z "$arr_line"; then - continue - fi - # Check for container - cont_line= - cont=$(echo "$arr_line" | sed -n "s/.*container=\([0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}:[0-9a-z]\{8\}\).*/\1/p") - if [ -n "$cont" ]; then - cnt_dup=0 - for cnt in $cont_list; do - if [ x"$cont"= x"$cnt" ]; then - cnt_dup=1 - fi - done - if [ $cnt_dup -eq 0 ]; then - cont_list="$cont_list $cont" - cont_line=$(echo "$mdadm_conf" | grep "UUID=$cont") - cont_line="$cont_line\n" - fi - fi - # add a line with the "real" md device name so that boot-md.sh finds it - cfg_dev=$(echo "$arr_line" | sed -rn 's/^ARRAY +([^ ]*).*/\1/p; T; q') - real_dev=$(readlink -f "$cfg_dev") - if test -n "$real_dev" -a "$real_dev" != "$cfg_dev"; then - arr_line="$arr_line$(echo -e "\\n$arr_line" | \ - sed -r "s:^(ARRAY +)$cfg_dev:\\1$real_dev:")" - fi - mdblockdev="$mdblockdev $md_tmpblockdev" - # Add ARRAY line (with container line before if needed). - cfg_line=$(echo -e "$cont_line$arr_line") - eval md_conf_${md_dev}=\""$cfg_line"\" - md_devs="$md_devs $md_dev" - root_md=1 + mdconf=$(mdadm -Db "$bd") + if test -z "$mdconf"; then + mdblockdev="$mdblockdev $bd" + continue fi + md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p") + mdblockdev="$mdblockdev $md_tmpblockdev" + md_devs="$md_devs $md_dev" + container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p') + for cnt in $cont_list; do + if [ x"$container"= x"$cnt" ]; then + container= + break + fi + done + case "$container" in + "") + ;; + /dev/*) + mdconf="$(mdadm -Db "$container")\\n$mdconf" + ;; + [0-9a-f]*[0-9a-f]) + mdconf="$(mdadm -Ebs | grep "UUID=$container")\\n$mdconf" + ;; + *) + echo "unrecognized container for $md_dev: $container" + ;; + esac + eval md_conf_${md_dev}=\"$mdconf\" + root_md=1 done # Any 'md' device is replaced by it's component disks.