The initramfs executes /scripts/local-top/mdadm to handle raid. In that script is the statement
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
With the version of mdadm shipping with Debian Jessie, the --run parameter seems to be ignored when used in conjunction with --scan. According to the man page it is supposed to activate all arrays even if they are degraded. But instead, any arrays that are degraded are marked as 'inactive'. If the root filesystem is on one of those inactive arrays, the boot process is halted.
It is possible to modify this script and then rebuild the initramfs with the command update-initramfs -u
.
- Copy the script to the local override directory
- Patch the script with some additional lines to run
mdadm --run
on each array individually if the first attempt fails.
- Update the initramfs.
The following commands will perform the previous steps. Verify that you don't already have a /etc/initramfs-tools/scripts/local-top/mdadm file before you copy on top of it.
cd /etc/initramfs-tools/scripts/local-top
cp /usr/share/initramfs-tools/scripts/local-top/mdadm .
patch --verbose --ignore-whitespace <<'EndOfPatch'
--- mdadm
+++ mdadm
@@ -76,7 +76,15 @@
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."
+ log_warning_msg "failed to assemble all arrays...attempting individual starts"
+ for dev in $(cat /proc/mdstat | grep md | cut -d ' ' -f 1); do
+ log_begin_msg "attempting mdadm --run $dev"
+ if $MDADM --run $dev; then
+ verbose && log_success_msg "started $dev"
+ else
+ log_failure_msg "failed to start $dev"
+ fi
+ done
fi
verbose && log_end_msg
EndOfPatch
update-initramfs -u
With this updated initramfs, it is possible to boot without intervention when a RAID1 containing the root filesystem is missing a drive.