Greetings, Following up on the idea in the prior post, I've hacked up a script which can go in /etc/mkinitramfs/scripts/local-top/ (called 'md', attached) which will work without depending on the local mdadm.conf file. This means the initrd image will work even if the mdadm.conf on the root partition of the system becomes corrupt or out of date. This is a much better/cleaner solution than using mdrun.
Note that this works with the existing 'md' hook script in the
initramfs-tools package. If that is removed then the mdadm package
would also need to install a 'hook' script into /etc/mkinitramfs/hooks
to do what the initramfs-tools script is doing now (namely, copying
the mdadm binary and the md modules into the appropriate places).
Thanks!
Stephen
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
unset raidlvl
gotraid=n
# Detect raid level
for x in /dev/hd[a-z][0-9]* /dev/sd[a-z][0-9]*; do
if [ ! -e ${x} ]; then
continue
fi
raidlvl=$(mdadm --examine ${x} 2>/dev/null | grep "Level" | sed -e
's/.*Raid Level : \(.*\)/\1/')
if [ "$raidlvl" ]; then
modprobe -q ${raidlvl} 2>/dev/null
gotraid=y
fi
done
[ "${gotraid}" = y ] || exit
mkdir /etc/mdadm
echo "DEVICE partitions" > /etc/mdadm/mdadm.conf
/sbin/mdadm --examine --scan | sed -e 's: /dev/\.tmp\.: /dev/:' >>
/etc/mdadm/mdadm.conf
/sbin/mdadm -A -s -a
signature.asc
Description: Digital signature

