r142 - in mdadm/trunk/debian: . initramfs
madduck at users.alioth.debian.org
madduck at users.alioth.debian.org
Wed Aug 23 14:18:30 UTC 2006
Author: madduck
Date: 2006-08-23 14:18:29 +0000 (Wed, 23 Aug 2006)
New Revision: 142
Modified:
mdadm/trunk/debian/changelog
mdadm/trunk/debian/initramfs/hook
mdadm/trunk/debian/initramfs/script.local-top
mdadm/trunk/debian/mdadm.config
Log:
* Improved initramfs hook; now does not rely on initramfs to provide RAID
assembly:
- if a checked mdadm.conf file is present, use that.
- if an unchecked mdadm.conf is present, create a temporary one
- if that fails, use the unchecked one iff it contains at least one
ARRAY statement. Otherwise rely on auto-generation from the initramfs
during the book (and hope for the best).
- if no mdadm.conf is found, create one on the fly
- if that fails, hope that the auto-generation will work during boot
* Improved the messages printed by the initramfs script.
* Do not store the debconf answer for whether arrays not listed in the
configuration file should be used.
* Now asks again for the devices to start (preseeded with 'all') if the user
does not want to proceed with devices not listed in the configuration
file.
Modified: mdadm/trunk/debian/changelog
===================================================================
--- mdadm/trunk/debian/changelog 2006-08-22 20:20:52 UTC (rev 141)
+++ mdadm/trunk/debian/changelog 2006-08-23 14:18:29 UTC (rev 142)
@@ -2,8 +2,23 @@
* Allow ARRAY lines in configuration file to break across lines
(closes: #384222).
+ * Improved initramfs hook; now does not rely on initramfs to provide RAID
+ assembly:
+ - if a checked mdadm.conf file is present, use that.
+ - if an unchecked mdadm.conf is present, create a temporary one
+ - if that fails, use the unchecked one iff it contains at least one
+ ARRAY statement. Otherwise rely on auto-generation from the initramfs
+ during the book (and hope for the best).
+ - if no mdadm.conf is found, create one on the fly
+ - if that fails, hope that the auto-generation will work during boot
+ * Improved the messages printed by the initramfs script.
+ * Do not store the debconf answer for whether arrays not listed in the
+ configuration file should be used.
+ * Now asks again for the devices to start (preseeded with 'all') if the user
+ does not want to proceed with devices not listed in the configuration
+ file.
- -- martin f. krafft <madduck at debian.org> Tue, 22 Aug 2006 21:14:55 +0100
+ -- martin f. krafft <madduck at debian.org> Wed, 23 Aug 2006 15:14:59 +0100
mdadm (2.5.3.git200608202239-1) unstable; urgency=low
Modified: mdadm/trunk/debian/initramfs/hook
===================================================================
--- mdadm/trunk/debian/initramfs/hook 2006-08-22 20:20:52 UTC (rev 141)
+++ mdadm/trunk/debian/initramfs/hook 2006-08-23 14:18:29 UTC (rev 142)
@@ -43,78 +43,123 @@
[ -r /usr/share/initramfs-tools/hook-functions ] || exit 0
. /usr/share/initramfs-tools/hook-functions
+# copy the binary as early as possible
+copy_exec $MDADM /sbin
+
+# copy all modules into the initramfs, just for safety.
+# we copy raid456 / raid5+raid6 because the hook script just won't do
+# anything when the module cannot be found.
+modules="linear multipath raid0 raid1 raid456 raid5 raid6 raid10"
+for mod in $modules; do manual_add_modules $mod; done
+
+# read in the configuration
CONFIG=/etc/mdadm/mdadm.conf
ALTCONFIG=/etc/mdadm.conf
+[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG || :
-[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG
+DEBIANCONFIG=/etc/default/mdadm
+INITRDSTART=all
+[ -s $DEBIANCONFIG ] && . $DEBIANCONFIG
+[ -z "$INITRDSTART" ] && INITRDSTART=none
+
+DESTMDADMCONF=$DESTDIR/etc/mdadm/mdadm.conf
+DESTCONFIG=$DESTDIR/conf/md.conf
+
+# save the homehost for now, even if we don't use it yet
if [ -f $CONFIG ]; then
- if [ -e /var/lib/mdadm/CONF-UNCHECKED ]; then
- # the file comes from an old installation and hence is not guaranteed to
- # work. We thus refuse to work.
+ homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
+fi
+if [ -z "${homehost:-}" ] || [ "${homehost:-}" = '<system>' ]; then
+ homehost="$(hostname)"
+fi
+echo "MD_HOMEHOST='$homehost'" > $DESTCONFIG
- echo "E: mdadm: unchecked mdadm.conf file found." >&2
- echo "I: mdadm: please read /usr/share/doc/mdadm/README.upgrading-2.5.3.gz ." >&2
- echo "I: mdadm: leaving RAID initialisation to initramfs (mdrun) for now." >&2
- exit 0
- fi
+install_config()
+{
+ # install the configuration file
+ mkdir -p ${2%/*}
+ # only copy ARRAY and DEVICE lines, and merge continuation lines into one
+ sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE)/P;D' $1 > $2
+}
-else
+if [ ! -f $CONFIG ]; then
# there is no configuration file, so let's create one
+
if /usr/share/mdadm/mkconf generate $CONFIG; then
+ # all is well
+ install_config $CONFIG $DESTMDADMCONF
echo "I: mdadm: auto-generated the mdadm.conf configuration file." >&2
else
- echo "E: mdadm: failed to autogenerate the mdadm.conf file." >&2
- echo "I: mdadm: leaving RAID initialisation to initramfs (mdrun) for now." >&2
+ # we failed to auto-generate, so remove the file and let the emergency
+ # procedure take over
rm -f $CONFIG
- exit 0
+ echo "W: mdadm: failed to auto-generate the mdadm.conf file." >&2
+ echo "W: mdadm: please read /usr/share/doc/mdadm/README.upgrading-2.5.3.gz ." >&2
fi
-fi
+
+else
+
+ if [ -e /var/lib/mdadm/CONF-UNCHECKED ]; then
+ # the file comes from an old installation and hence is not guaranteed to
+ # work. We thus better create one and start all arrays to be sure.
-# install the configuration file
-mkdir -p $DESTDIR/etc/mdadm
-sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE)/P;D' \
- < $CONFIG > $DESTDIR/etc/mdadm/mdadm.conf
+ echo "W: mdadm: unchecked configuration file: $CONFIG" >&2
+ echo "W: mdadm: please read /usr/share/doc/mdadm/README.upgrading-2.5.3.gz ." >&2
-# obtain dev:level pairs from config file, honouring multiline entries
-devpairs="$(
- while read line; do
- for atom in $line; do
- case "$atom" in
- (/dev*) dev=$atom;;
- (level=*) level=${atom#level=};;
- (*) :;;
- esac
- done
- [ -n "${dev:-}" ] && echo -n "${dev}:${level} "
- done < $DESTDIR/etc/mdadm/mdadm.conf)"
+ tmpfile="${DESTMDADMCONF}.tmp"
+ if /usr/share/mdadm/mkconf generate $tmpfile; then
+ # all is well, we now have a temporary configuration file
+ echo "I: mdadm: auto-generated temporary mdadm.conf configuration file." >&2
+ install_config $tmpfile $DESTMDADMCONF
+ else
+ # stuff's really broke, as we failed to generate a temporary file.
+ # let's hope the unchecked file works, provided it contains at least one
+ # ARRAY statement...
+ echo "W: mdadm: failed to auto-generate temporary mdadm.conf file." >&2
+ if grep -q '^ARRAY' $CONFIG; then
+ echo "W: mdadm: using the unchecked file and hoping for the best..." >&2
+ install_config $CONFIG $DESTMDADMCONF
+ else
+ echo "W: mdadm: no ARRAYs defined in unchecked mdadm.conf, cannot use..." >&2
+ fi
+ fi
+ rm -f $tmpfile
-copy_exec $MDADM /sbin
+ else
+ # this is the ideal case
+ install_config $CONFIG $DESTMDADMCONF
+ echo "I: mdadm: using configuration file: $CONFIG" >&2
+ fi
-# copy all modules into the initramfs, just for safety.
-# we copy raid456 / raid5+raid6 because the hook script just won't do
-# anything when the module cannot be found.
-modules="linear multipath raid0 raid1 raid456 raid5 raid6 raid10"
-for mod in $modules; do manual_add_modules $mod; done
+fi
+# if at this point, $DESTMDADMCONF does not exist, we must let the initramfs
+# handle stuff.
+if [ ! -f $DESTMDADMCONF ]; then
+ echo "W: mdadm: falling back to emergency procedure in initramfs." >&2
+ exit 0
+else
+ # obtain dev:level pairs from config file, honouring multiline entries
+ devpairs="$(
+ while read line; do
+ for atom in $line; do
+ case "$atom" in
+ (/dev*) dev=$atom;;
+ (level=*) level=${atom#level=};;
+ (*) :;;
+ esac
+ done
+ [ -n "${dev:-}" ] && echo -n "${dev}:${level} "
+ done < $DESTMDADMCONF)"
+fi
+
uniquify()
{
for i in $@; do echo "$i"; done | sort -u
}
-DEBIANCONFIG=/etc/default/mdadm
-INITRDSTART=all
-[ -s $DEBIANCONFIG ] && . $DEBIANCONFIG
-
-# save the homehost for now, even if we don't use it yet
-homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
-if [ -z "$homehost" ] || [ "$homehost" = '<system>' ]; then
- homehost="$(hostname)"
-fi
-echo "MD_HOMEHOST='$homehost'" > $DESTDIR/conf/md.conf
-
-[ -z "$INITRDSTART" ] && INITRDSTART=none
if [ "$INITRDSTART" != none ] && [ -n "$devpairs" ]; then
- echo "MD_DEVPAIRS='${devpairs% }'" >> $DESTDIR/conf/md.conf
+ echo "MD_DEVPAIRS='${devpairs% }'" >> $DESTCONFIG
devs=''; levels=''
for i in $devpairs; do
@@ -143,11 +188,11 @@
break
done
- echo "MD_LEVELS='$levels'" >> $DESTDIR/conf/md.conf
+ echo "MD_LEVELS='$levels'" >> $DESTCONFIG
if [ "$INITRDSTART" = all ]; then
- echo "MD_DEVS=all" >> $DESTDIR/conf/md.conf
+ echo "MD_DEVS=all" >> $DESTCONFIG
else
- echo "MD_DEVS='$devs'" >> $DESTDIR/conf/md.conf
+ echo "MD_DEVS='$devs'" >> $DESTCONFIG
fi
# raid4 is handled by raid5
@@ -158,7 +203,7 @@
&& modules="$(echo $modules | sed -e 's,raid[456],raid456,g')"
modules="$(uniquify $modules | tr '\n' ' ')"
- echo "MD_MODULES='${modules% }'" >> $DESTDIR/conf/md.conf
+ echo "MD_MODULES='${modules% }'" >> $DESTCONFIG
if [ "$INITRDSTART" = all ]; then
echo "I: mdadm: will start all available MD arrays from the initial ramdisk." >&2
@@ -169,7 +214,7 @@
fi
else
- echo "MD_DEVS=none" >> $DESTDIR/conf/md.conf
+ echo "MD_DEVS=none" >> $DESTCONFIG
echo "I: mdadm: no MD arrays will be started from the initial ramdisk." >&2
fi
Modified: mdadm/trunk/debian/initramfs/script.local-top
===================================================================
--- mdadm/trunk/debian/initramfs/script.local-top 2006-08-22 20:20:52 UTC (rev 141)
+++ mdadm/trunk/debian/initramfs/script.local-top 2006-08-23 14:18:29 UTC (rev 142)
@@ -26,7 +26,7 @@
. /scripts/functions
if [ -e /scripts/local-top/md ]; then
- log_failure_msg "old md initialisation script found, getting out of its way..."
+ log_warning_msg "old md initialisation script found, getting out of its way..."
exit 1
fi
@@ -51,7 +51,7 @@
if modprobe --syslog "$module"; then
verbose && log_success_msg "loaded module ${module}."
else
- verbose && log_failure_msg "failed to load module ${module}."
+ log_failure_msg "failed to load module ${module}."
fi
done
log_end_msg
@@ -65,36 +65,42 @@
mkdir --parent /dev/md
CONFIG=/etc/mdadm/mdadm.conf
-# this really should not be needed, but also doesn't hurt.
-[ -e $CONFIG ] || \
+# in case the hook failed to install a configuration file, this is out last
+# attempt... the "emergency procedure"... <drumroll>
+if [ ! -e $CONFIG ]; then
+ log_warning_msg "missing mdadm.conf file, trying to create one..."
+ mkdir -p ${CONFIG%/*}
$MDADM --examine --scan --config=partitions > $CONFIG
+ if [ -s $CONFIG ]; then
+ verbose && log_success_msg "mdadm.conf created."
+ else
+ verbose && log_failure_msg "could not create mdadm.conf, the boot will likely fail."
+ fi
+ MD_DEVS=all
+fi
if [ "$MD_DEVS" = all ]; then
verbose && log_begin_msg "Assembling all MD arrays"
-
extra_args=''
[ -n "$MD_HOMEHOST" ] && \
extra_args="--homehost='$MD_HOMEHOST' --auto-update-homehost"
if $MDADM --assemble --scan --run --auto=yes $extra_args; then
- verbose && log_success_msg "success"
+ verbose && log_success_msg "assembled all arrays."
else
- verbose && log_failure_msg "failed"
+ log_failure_msg "failed to assemble all arrays."
fi
-
verbose && log_end_msg
elif [ "$MD_DEVS" != none ]; then
for dev in $MD_DEVS; do
verbose && log_begin_msg "Assembling MD array $dev"
-
if $MDADM --assemble --run --auto=yes $dev; then
verbose && log_success_msg "started $dev"
else
- verbose && log_failure_msg "failed to start $dev"
+ log_failure_msg "failed to start $dev"
fi
-
verbose && log_end_msg
done
Modified: mdadm/trunk/debian/mdadm.config
===================================================================
--- mdadm/trunk/debian/mdadm.config 2006-08-22 20:20:52 UTC (rev 141)
+++ mdadm/trunk/debian/mdadm.config 2006-08-23 14:18:29 UTC (rev 142)
@@ -67,13 +67,22 @@
db_capb escape
-msg=intro; suffix=''
+msg=intro; suffix=''; error=0
while true; do
db_metaget mdadm/initrdstart_msg_${msg} extended_description || :
db_subst mdadm/initrdstart msg "$(echo -e "${RET}${suffix}" | debconf-escape -e)"
ret=0; db_input low mdadm/initrdstart || ret=$?
db_go
+ if [ $error -ne 0 ] && [ $ret -eq 30 ]; then
+ # there was an error in a previous run of this loop, but the above question
+ # was not asked, so we better exit the endless loop...
+ echo "W: unable to determine MD arrays needed for boot." >&2
+ echo "W: falling back to starting all of them..." >&2
+ INITRDSTART=all
+ break
+ fi
+
db_get mdadm/initrdstart
INITRDSTART="$(echo $RET | tr , ' ')"
@@ -83,7 +92,6 @@
*)
arrays=''
- error=0
for i in $INITRDSTART; do
# standardise by prefixing /dev/
@@ -117,6 +125,8 @@
&& egrep -q "^(ARRAY)?[[:space:]]+$t([[:space:]]|$)+" $CONFIG; then
i="$t"
else
+ db_set mdadm/initrdstart_notinconf false
+ db_fset mdadm/initrdstart_notinconf seen false
db_subst mdadm/initrdstart_notinconf array "$i"
db_subst mdadm/initrdstart_notinconf config "$CONFIG"
db_input high mdadm/initrdstart_notinconf || :
@@ -124,8 +134,10 @@
db_get mdadm/initrdstart_notinconf
if [ "$RET" = true ]; then
md5sum $CONFIG > /var/lib/mdadm/CONF-UNCHECKED
+ error=0
else
db_fset mdadm/initrdstart seen false
+ db_set mdadm/initrdstart all
error=1; msg=errconf; suffix=": $i"; break
fi
fi
@@ -141,13 +153,6 @@
# exit the while true loop
break
fi
-
- if [ $ret -eq 30 ]; then
- echo "W: unable to determine MD arrays needed for boot." >&2
- echo "W: falling back to starting all of them..." >&2
- INITRDSTART=all
- break
- fi
;;
esac
done
More information about the pkg-mdadm-commits
mailing list