summaryrefslogtreecommitdiff
path: root/debian/initramfs
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2016-07-02 19:16:01 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2016-07-02 19:16:01 +0100
commit6449d8e5351269369b06a7bb4421ca809cfc9f84 (patch)
tree3cb83259723d112fd7b08b5bd299df2f5ee94009 /debian/initramfs
parent3daa86f837ad5bd61f2240a6a0303b19397e0e31 (diff)
parentb83f8fcaffa542498c5698a3a161b9967ac1d3d6 (diff)
Record mdadm (3.4-2) in archive suite sid
Diffstat (limited to 'debian/initramfs')
-rw-r--r--debian/initramfs/hook264
-rw-r--r--debian/initramfs/script.local-block44
-rw-r--r--debian/initramfs/script.local-bottom3
-rw-r--r--debian/initramfs/script.local-top101
4 files changed, 101 insertions, 311 deletions
diff --git a/debian/initramfs/hook b/debian/initramfs/hook
index 74ed7e38..ae7d4d18 100644
--- a/debian/initramfs/hook
+++ b/debian/initramfs/hook
@@ -7,10 +7,10 @@
#
set -eu
-PREREQ=
+PREREQ="udev"
prereqs()
{
- echo "$PREREQ"
+ echo "$PREREQ"
}
case "${1:-}" in
@@ -44,223 +44,67 @@ warn()
write W "$@"
}
-err()
-{
- write E "$@"
-}
-
-MDADM=/sbin/mdadm
-MDMON=/sbin/mdmon
-[ -x "$MDADM" ] || exit 0
-
-[ -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_exec $MDMON /sbin
+copy_exec /sbin/mdadm /sbin
+copy_exec /sbin/mdmon /sbin
+
+# Copy udev rules, which udev no longer does
+for UDEV_RULE in 63-md-raid-arrays.rules 64-md-raid-assembly.rules; do
+for rules_folder in /lib/udev/rules.d /etc/udev/rules.d; do
+ if [ -f $rules_folder/$UDEV_RULE ]; then
+ mkdir -p $DESTDIR$rules_folder
+ cp $rules_folder/$UDEV_RULE $DESTDIR$rules_folder/$UDEV_RULE
+ fi
+done
+done
-# 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
+# load raid modules in the initramfs
+for module in linear multipath raid0 raid1 raid456 raid5 raid6 raid10; do
+ force_load $module
+done
-# read in the configuration
+# copy the mdadm configuration
CONFIG=/etc/mdadm/mdadm.conf
ALTCONFIG=/etc/mdadm.conf
-[ ! -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/mdadm
-
-if [ -f $CONFIG ]; then
- homehost="$(sed -ne 's,^[[:space:]]*HOMEHOST[[:space:]]*,,p' $CONFIG)"
-fi
-if [ -z "${homehost:-}" ] || [ "${homehost:-}" = '<system>' ]; then
- echo "MD_HOMEHOST='$(hostname)'" > $DESTCONFIG
-fi
-
-install_config()
-{
- # install the configuration file
- mkdir -p ${2%/*}
- # only copy ARRAY/DEVICE/HOMEHOST/AUTO lines, and merge continuation lines into one
- if [ -f "$1" ] ; then
- sed -e :a -re '$!N;s/\n[[:space:]]+/ /;ta' -ne '/^(ARRAY|DEVICE|HOMEHOST|AUTO)/P;D' $1 > $2
- fi
-}
+[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG || :
+mkdir -p ${DESTDIR}/etc/mdadm
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
- info "auto-generated the mdadm.conf configuration file."
- else
- # we failed to auto-generate, so let the emergency procedure take over
- warn "failed to auto-generate the mdadm.conf file."
- fi
-
+ # there is no configuration file, so let's create one
+ if /usr/share/mdadm/mkconf generate $CONFIG; then
+ # all is well
+ cp -p $CONFIG $DESTMDADMCONF
+ info "auto-generated the mdadm.conf configuration file."
+ else
+ # we failed to auto-generate, so let the emergency procedure take over
+ warn "failed to auto-generate the mdadm.conf file."
+ warn "please read /usr/share/doc/mdadm/README.upgrading-2.5.3.gz ."
+ fi
else
-
- if grep -q '^ARRAY' $CONFIG; then
-
- # this is the ideal case
- install_config $CONFIG $DESTMDADMCONF
- info "using configuration file: $CONFIG"
-
- else
-
- # the file defines no ARRAYs. We better create a temporary file to be sure.
-
- warn "$CONFIG defines no arrays."
-
- mkdir --parents ${DESTMDADMCONF%/*}
- tmpfile="${DESTMDADMCONF}.tmp"
- if /usr/share/mdadm/mkconf > $tmpfile; then
- # all is well, we now have a temporary configuration file
- info "auto-generated temporary mdadm.conf configuration file."
- 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...
- warn "failed to auto-generate temporary mdadm.conf file."
- if grep -q '^ARRAY' $CONFIG; then
- warn "using the unchecked file and hoping for the best..."
- install_config $CONFIG $DESTMDADMCONF
- fi
- fi
- rm -f $tmpfile
-
- fi
-
-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."
- exit 0
-elif ! grep -q '^ARRAY' $DESTMDADMCONF; then
- warn "no arrays defined in configuration file."
- info "letting initramfs assemble auto-detected arrays."
- exit 0
-else
- # obtain devices list from config file, honouring multiline entries
- devices="$(
- dev=
- while read line; do
- case "$line" in
- (ARRAY*) :;;
- (*) continue;;
- esac
- for atom in $line; do
- case "$atom" in
- (/dev*) dev=$atom;;
- esac
- done
-
- # /dev/mdX and /dev/md/X are the same, really
- case "$dev" in
- "") continue ;;
- (/dev/md/*) alt=/dev/md${dev##*/};;
- (/dev/md*) alt=/dev/md/${dev#/dev/md};;
- (*)
- err "unknown device encountered: $dev"
- warn_emergency
- exit 0
- ;;
- esac
- if [ ! -b "$dev" ] && [ -b "$alt" ]; then
- dev="$alt"
- fi
-
- echo "$dev"
- done < $DESTMDADMCONF)" || exit $?
-fi
-
-if [ "$INITRDSTART" != none ] && [ -n "$devices" ]; then
-
- devs=
- for dev in $devices; do
- case "$INITRDSTART " in
- all|*${dev}[[:space:]]*)
- case "$devs " in # uniquiness
- (*${dev}\ *) :;;
- (*) devs="${devs:+$devs }$dev" ;;
- esac
- ;;
- *) :;;
- esac
- done
-
- # make sure the configuration file knows about all running devices
- $MDADM --detail --scan | while read array device params; do
- uuid=${params#*UUID=}; uuid=${uuid%% *}
- if ! grep -qi "uuid=$uuid" $DESTMDADMCONF; then
- warn "the array $device with UUID $uuid"
- warn "is currently active, but it is not listed in mdadm.conf. if"
- warn "it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!"
- warn "please inspect the output of /usr/share/mdadm/mkconf, compare"
- warn "it to $CONFIG, and make the necessary changes."
- fi
- done
-
- for i in $INITRDSTART; do
- case "$INITRDSTART" in all) break;; *) :;; esac
- case "$devs" in
- *${i}*) continue;;
- *) :;;
- esac
-
- warn "I am supposed to start $i from the initial ramdisk,"
- warn "yet I cannot find the array in the configuration file."
- warn "I am thus reverting to starting all arrays."
- INITRDSTART=all
- break
- done
-
- if [ "$INITRDSTART" = all ]; then
- echo "MD_DEVS=all" >> $DESTCONFIG
- else
- echo "MD_DEVS='$devs'" >> $DESTCONFIG
- fi
-
- if [ "$INITRDSTART" = all ]; then
- info "will start all available MD arrays from the initial ramdisk."
- else
- for i in $devs; do
- info "will start MD array $i from the initial ramdisk."
- done
- fi
-
- # Copy udev rules, which udev no longer does
- for rules_file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules
- do
- for rules_folder in /lib/udev/rules.d /etc/udev/rules.d; do
- if [ -f $rules_folder/$rules_file ]; then
- mkdir -p $DESTDIR$rules_folder
- cp $rules_folder/$rules_file $DESTDIR$rules_folder/$rules_file
- fi
- done
- done
-
-else
- echo "MD_DEVS=none" >> $DESTCONFIG
- info "no MD arrays will be started from the initial ramdisk."
+ cp -p $CONFIG ${DESTDIR}/etc/mdadm
+ sed -i '/^CREATE/s/^/#/' $DESTMDADMCONF
+ if ! grep -q '^ARRAY' $CONFIG; then
+ tmpfile="${DESTMDADMCONF}.tmp"
+ warn "$CONFIG defines no arrays."
+ if /usr/share/mdadm/mkconf > $tmpfile; then
+ cp -p $tmpfile $DESTMDADMCONF
+ else
+ warn "failed to auto-generate temporary mdadm.conf file."
+ fi
+ else
+ # make sure the configuration file knows about all running devices
+ /sbin/mdadm --detail --scan | while read array device params; do
+ uuid=${params#*UUID=}; uuid=${uuid%% *}
+ if ! grep -q "UUID=$uuid" $DESTMDADMCONF; then
+ warn "the array $device with UUID $uuid"
+ warn "is currently active, but it is not listed in mdadm.conf. if"
+ warn "it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!"
+ warn "please inspect the output of /usr/share/mdadm/mkconf, compare"
+ warn "it to $CONFIG, and make the necessary changes."
+ fi
+ done
+ fi
fi
-
-# only output this on Debian systems
-[ -s /etc/default/mdadm ] && \
- info 'use `dpkg-reconfigure --priority=low mdadm` to change this.'
-
-exit 0
diff --git a/debian/initramfs/script.local-block b/debian/initramfs/script.local-block
new file mode 100644
index 00000000..e9b47c3d
--- /dev/null
+++ b/debian/initramfs/script.local-block
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+PREREQ="multipath"
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# Poor man's mdadm-last-resort@.timer
+# That kicks in 2/3rds into the ROOTDELAY
+
+if [ ! -f /run/count.mdadm.initrd ]
+then
+ COUNT=0
+else
+ COUNT=$(cat /run/count.mdadm.initrd)
+fi
+COUNT=$((COUNT + 1))
+
+echo $COUNT > /run/count.mdadm.initrd
+
+MAX=30
+if [ ${ROOTDELAY:-0} -gt $MAX ]; then
+ MAX=$ROOTDELAY
+fi
+MAX=$((MAX*2/3))
+
+if [ "$COUNT" = "$MAX" ]
+then
+ # Poor man's mdadm-last-resort@.service
+ mdadm -q --run /dev/md?*
+ rm -f /run/count.mdadm.initrd
+fi
+
+exit 0
diff --git a/debian/initramfs/script.local-bottom b/debian/initramfs/script.local-bottom
new file mode 100644
index 00000000..eda3b179
--- /dev/null
+++ b/debian/initramfs/script.local-bottom
@@ -0,0 +1,3 @@
+#!/bin/sh
+rm -f /run/count.mdadm.initrd
+exit 0 \ No newline at end of file
diff --git a/debian/initramfs/script.local-top b/debian/initramfs/script.local-top
deleted file mode 100644
index 9450bb72..00000000
--- a/debian/initramfs/script.local-top
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/sh
-#
-# Copyright © 2006-2008 Martin F. Krafft <madduck@debian.org>,
-# 2012 Michael Tokarev <mjt@tls.msk.ru>
-# based on the scripts in the initramfs-tools package.
-# released under the terms of the Artistic Licence.
-#
-set -eu
-
-case ${1:-} in
- prereqs) echo "multipath"; exit 0;;
-esac
-
-. /scripts/functions
-
-maybe_break pre-mdadm
-
-if [ -e /scripts/local-top/md ]; then
- log_warning_msg "old md initialisation script found, getting out of its way..."
- exit 0
-fi
-
-MDADM=/sbin/mdadm
-[ -x "$MDADM" ] || exit 0
-
-verbose()
-{
- case "$quiet" in y*|Y*|1|t*|T*)
- return 1;;
- *)
- return 0;;
- esac
-}
-
-MD_DEVS=all
-[ -s /conf/mdadm ] && . /conf/mdadm
-
-if [ "$MD_DEVS" = none ]; then
- verbose &&
- log_warning_msg "INITRDSTART set to \"none\" in /etc/default/mdadm, not assembling raid arrays"
- exit 0
-fi
-
-if [ ! -f /proc/mdstat ] && ! modprobe -q md_mod; then
- verbose && log_warning_msg "failed to load module md_mod."
-fi
-if [ ! -f /proc/mdstat ]; then
- verbose && log_warning_msg "cannot initialise MD subsystem (/proc/mdstat missing)"
- exit 0
-fi
-
-# handle /dev/md/X nodes
-mkdir -p /dev/md
-
-CONFIG=/etc/mdadm/mdadm.conf
-# in case the hook failed to install a configuration file, this is our last
-# attempt... the "emergency procedure"... <drumroll>
-if [ ! -e $CONFIG ]; then
- log_warning_msg "missing mdadm.conf file, trying to create one..."
- mkdir -p ${CONFIG%/*}
- echo DEVICE partitions > $CONFIG
- $MDADM --examine --scan >> $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"
- if $MDADM --assemble --scan --run --auto=yes${extra_args:+ $extra_args}; then
- verbose && log_success_msg "assembled all arrays."
- else
- log_failure_msg "failed to assemble all arrays."
- fi
- verbose && log_end_msg
-
-else
- for dev in $MD_DEVS; do
-
- verbose && log_begin_msg "Assembling MD array $dev"
- if $MDADM --assemble --scan --run --auto=yes $dev; then
- verbose && log_success_msg "started $dev"
- else
- log_failure_msg "failed to start $dev"
- fi
- verbose && log_end_msg
-
- done
-fi
-
-wait_for_udev 10
-
-maybe_break post-mdadm
-
-exit 0