From b593e3099a7cb1b2684211aee314c52d5cb8201eeaaae2e270ace573dcc453e4 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 15 Jan 2010 16:44:42 +0000 Subject: [PATCH] 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.