#!/bin/sh
-MD_RCSID='$Revision$ $Date:: $'
-
# geninitrd mod: mdadm
USE_MD=${USE_MD:-yes}
# setup geninitrd module
# @access public
setup_mod_md() {
- mdassemble=$(find_tool $initrd_dir/mdassemble /sbin/initrd-mdassemble)
- if [ ! -x "$mdassemble" ]; then
- USE_MD=no
- fi
mdadm=$(find_tool /sbin/mdadm $initrd_dir/mdadm /sbin/initrd-mdadm)
if [ ! -x "$mdadm" ]; then
USE_MD=no
local found raidlevel
if [ -f /etc/mdadm.conf ]; then
- debug "Finding RAID details using mdadm for rootdev=$1"
+ verbose "Finding RAID details using mdadm for rootdev=$1"
eval `($mdadm -v --examine --scan --config=/etc/mdadm.conf 2> /dev/null;$mdadm -v --detail --scan --config=/etc/mdadm.conf 2> /dev/null) | awk -v rootdev="$1" '
BEGIN {
found = "no";
die "RAID devices not found for \"$1\", check your configuration!"
fi
- debug "md: found rootdev=$1 on device $rootdev_new with devices list ${dev_list}"
+ verbose "md: found rootdev=$1 on device $rootdev_new with devices list ${dev_list}"
rootdev_nr=$(( $rootdev_nr + 1 ))
eval "rootdev${rootdev_nr}=\"$rootdev_new\""
if ! is_yes "$have_md"; then
return
fi
- debug "Setting up mdadm..."
+ verbose "Setting up mdadm..."
+
+ inst_exec $mdadm /sbin/mdadm
- inst_exec $mdassemble /bin/mdassemble
+ echo "DEVICE partitions containers" >> "$DESTDIR/etc/mdadm.conf"
# LVM on RAID case
local dev_list_extra ex_dev
dev_list_extra=$(awk '/^DEVICE / { for (i=2; i<=NF; i++) { printf "%s ", $i; }; } ' /etc/mdadm.conf | xargs)
new_dev_list_extra=""
for ex_dev in $dev_list_extra; do
- if [ "$ex_dev" = "partitions" ]; then
- echo "DEVICE partitions" >> "$DESTDIR/etc/mdadm.conf"
+ if [ "$ex_dev" = "partitions" -o "$ex_dev" = "containers" ]; then
+ echo "DEVICE $ex_dev" >> "$DESTDIR/etc/mdadm.conf"
# FIXME: find and copy partition devices from /proc/partitions
# - best if done at runtime, now initrd gen time
continue
for nr in `seq 1 $rootdev_nr`; do
eval cr_rootdev="\$rootdev${nr}"
eval cr_dev_list="\$dev_list${nr}"
- debug echo "Setting up array ($cr_rootdev = $cr_dev_list)"
+ verbose "Setting up array ($cr_rootdev = $cr_dev_list)"
[ "$cr_rootdev" = "/dev/md0" ] && do_md0=0
done
done
- echo "mdassemble" | add_linuxrc
+ echo "wait_for_files $cr_dev_list" | add_linuxrc
+ add_linuxrc <<-'EOF'
+ /sbin/mdadm --assemble --scan
if [ "$DEBUGINITRD" ]; then
- echo "[ -e /proc/mdstat ] && echo "/proc/mdstat contents:" && cat /proc/mdstat" | add_linuxrc
+ [ -e /proc/mdstat ] && echo "/proc/mdstat contents:" && cat /proc/mdstat
fi
+ EOF
# needed to determine md-version
if [ "$do_md0" -eq 1 ]; then
- mknod $DESTDIR/dev/md0 b 9 0
+ mknod -m 660 $DESTDIR/dev/md0 b 9 0
fi
}