martin f. krafft: check for config file in incremental mode

Martin F. Krafft madduck at alioth.debian.org
Fri Jan 29 06:19:54 UTC 2010


Module: mdadm
Branch: incremental
Commit: e81720956056208767fd9d2edda8f066499f8a59
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=e81720956056208767fd9d2edda8f066499f8a59

Author: martin f. krafft <madduck at debian.org>
Date:   Fri Jan 29 18:51:54 2010 +1300

check for config file in incremental mode

mdadm.conf is kinda optional in incremental mode, but not really. It
would be optional if the homehost is properly encoded in the metadata of
all arrays, for then the super-minor or name could be used.

However, during the initramfs, the homehost is now known. Previously,
I worked around this by passing it via /conf/conf.d/md, but this does
not work so well now that mdadm is invoked by udev.

Therefore, mdadm needs mdadm.conf to obtain the target names (it uses
the UUID to determine that) and we cannot skip the mdadm.conf checks.

Signed-off-by: martin f. krafft <madduck at debian.org>

Conflicts:

	debian/changelog

---

 debian/changelog      |    3 ++-
 debian/initramfs/hook |   40 +++++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a0e79bd..3672f63 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,7 +5,8 @@ mdadm (3.1.1-2) UNRELEASED; urgency=low
     bugscript output.
   * Check active devices against configuration file based on UUID, not device
     name.
-  * When preparing the list of devices, treat /dev/mdX and /dev/md/X equally.
+  * Incremental mode does not make mdadm.conf obsolete, so do not skip the
+    sanity checks in the initramfs hook.
 
  -- martin f. krafft <madduck at debian.org>  Wed, 27 Jan 2010 14:42:16 +1300
 
diff --git a/debian/initramfs/hook b/debian/initramfs/hook
index dbc485f..432da8b 100644
--- a/debian/initramfs/hook
+++ b/debian/initramfs/hook
@@ -112,20 +112,6 @@ install_config()
   sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE|HOMEHOST)/P;D' $1 > $2
 }
 
-if is_true "$INCREMENTAL"; then
-  info "MD arrays are being incrementally assembled"
-  if [ -s $CONFIG ]; then
-    # mdadm.conf is optional with incremental assembly
-    install_config $CONFIG $DESTMDADMCONF
-  fi
-  exit 0
-fi
-
-homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
-if [ -z "${homehost:-}" ] || [ "${homehost:-}" = '<system>' ]; then
-  echo "MD_HOMEHOST='$(hostname)'" > $DESTCONFIG
-fi
-
 if [ ! -f $CONFIG ]; then
   # there is no configuration file, so let's create one
 
@@ -188,12 +174,12 @@ fi
 # if at this point, $DESTMDADMCONF does not exist or it does not contain any
 # ARRAY statements, we must let the initramfs handle stuff.
 if [ ! -f $DESTMDADMCONF ]; then
-  warn "no configuration file available."
-  info "letting initramfs assemble auto-detected arrays."
+  warn no configuration file available.
+  warn falling back to emergency procedure in initramfs.
   exit 0
 elif ! grep -q '^ARRAY' $DESTMDADMCONF; then
-  warn "no arrays defined in configuration file."
-  info "letting initramfs assemble auto-detected arrays."
+  warn no arrays defined in configuration file.
+  warn falling back to emergency procedure in initramfs.
   exit 0
 else
   # obtain dev:level pairs from config file, honouring multiline entries
@@ -212,7 +198,7 @@ else
             err "  $line"
             err "levels should be either raid*, linear, or multipath."
             warn "falling back to emergency procedure in initramfs."
-            exit 1
+            exit 0
             ;;
           (*) :;;
         esac
@@ -243,6 +229,22 @@ else
     done < $DESTMDADMCONF)" || exit $?
 fi
 
+if is_true "$INCREMENTAL"; then
+  info MD arrays are being incrementally assembled,
+  info thus not trying to figure out which arrays should be
+  info started at boot.
+
+  # only output this on Debian systems
+  [ -s /etc/default/mdadm ] && \
+    info 'use `dpkg-reconfigure --priority=medium mdadm` to change this.'
+  exit 0
+fi
+
+homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
+if [ -z "${homehost:-}" ] || [ "${homehost:-}" = '<system>' ]; then
+  echo "MD_HOMEHOST='$(hostname)'" > $DESTCONFIG
+fi
+
 if [ "$INITRDSTART" != none ] && [ -n "$devpairs" ]; then
   echo "MD_DEVPAIRS='${devpairs% }'" >> $DESTCONFIG
 




More information about the pkg-mdadm-commits mailing list