I put this together last night, and it's working ok on my servers.
YMMV.
It handles the job of first starting any dependent md devices
(IE for raid 0+1) for md devices in fstab set to mount at boot.
Might not be 100% fool proof if you have a VERY complex raidset.
Requires only bash/ash and sed. Have fun.
Dave
#!/bin/sh
# ./init.d/raidstart v991459491 2001-06-02
#
# Copyright 2001 'Diesel' Dave 'Kill a Cop' Cinege
# GPL2 - Copyright notice must remain
#
# Go through fstab. Start needed md devices and any dependent
# md devices.
#
# fstab and raidtab both MUST follow old or devfs style md
# names. (IE /dev/md10 OR /dev/md/10)
#
# This script depends on (bash|ash) & sed.
#
fstab=/etc/fstab
raidtab=/etc/raidtab
raidstart=/sbin/raidstart
[ -x "$raidstart" -a -f "$raidtab" -a -f "$fstab" ] || exit 0
maxlevel=4
tab=' '
md_depends() {
[ $# -eq 0 ] && return 1
md_devices="`sed -n "\-raiddev[ |$tab]*$1-,/raiddev/p" $raidtab | sed -n
"/device/s/.*device[ |$tab]*\(.*\)/\1/p"`"
#echo "$md_devices"
for device in $md_devices; do
#echo "$tab$device"
case $device in
/dev/md*) md_dep="$md_dep $device" ;;
esac
done
}
start () {
# Get md devices in fstab. Skip 'noauto' devices.
md_list0="`sed -n "/noauto/!s,^\(/dev/md[^ |$tab]*\).*,\1,p" $fstab`"
[ "$md_list0" = "" ] && exit 0 # No devices, bail happy
echo -n "Starting MD devices: "
# Loop through them and look for dependency md devices.
# Loop through those and so on or until we reach maxlevel. (runaway check)
x=0
while :; do
eval md_list=\"\$md_list$x\"
[ "$md_list" = "" ] && break
x=$(($x + 1))
[ $x -gt $maxlevel ] && break
md_dep=''
for md in $md_list; do
md_depends $md
[ "$md_dep" = "" ] || eval md_list$x=\"$md_dep\"
done
done
# We've made our lists. Run through them in reverse order
# to start dependancies first. (Hopefully : P)
while [ $x -gt 0 ]; do
x=$(($x - 1))
eval md_list=\"\$md_list$x\"
for md in $md_list; do
$raidstart $md >/dev/null 2>&1
[ $? -ne 0 ] && echo -n '!' # Failed. Prefix '!'
echo -n "${md##*/} "
done
done
echo
}
case "$1" in
start) start ;;
*) echo "Usage: `basename $0` start"; exit 1 ;;
esac
exit 0