--- /sbin/mkinitrd 2004-03-11 18:26:57 +0200 +++ /sbin/mkinitrd 2004-08-15 17:01:09 +0300 @@ -15,6 +15,14 @@ # Keith Owens # # Rewritten by Dmitry V. Levin +# +# Contributors: +# Nick S. Grechukh : +# Aug 15, 2004 improved raid support: +# - using LVM over raid +# - arrays created with mdadm (without /etc/raidtab) +# - loading raid support to initrd can be forced (for autodetect at bootstrap) +# bugs: raid-over-raid (level 10) will not working this way. however, formerly it wasn't working at all. PROG=mkinitrd VERSION=2.9.1 @@ -137,6 +145,10 @@ MODULES_CONF= HAVE_RAID= +PVSCAN=/sbin/pvscan +MDADM=/usr/sbin/mdadm +FORCE_RAID= + FSTAB_FILE=/etc/fstab BIN_SPLASH=/bin/splash @@ -292,10 +304,14 @@ { [ -z "$noraid" ] || return - if egrep -s '^/dev/md/?[0-9]+[ ]' "$FSTAB_FILE" | - fgrep -qsv noauto; then + if egrep -s '^/dev/md/?[0-9]+[ ]' "$FSTAB_FILE" | fgrep -qsv noauto \ + || [ -x $PVSCAN ] && $PVSCAN grep ACTIVE | egrep -q '"/dev/md/?[0-9]"' \ + || [ -n "$FORCE_RAID" ]; then +#### detects indirect using of raid arrays (e.g. via LVM) + HAVE_RAID=1 FindModule -md + if [ -f /etc/raidtab ]; then for number in $(grep '^[ ]*raid-level' /etc/raidtab | awk '{print $2}' |LC_COLLATE=C sort -u); do case "$number" in @@ -313,6 +329,38 @@ ;; esac done + fi + +#### detects arrays _without_ raidtab (e.g. created with mdadm). maybe rewrite to /proc/mdstat, heh? +#### of cource, it will detect only running arrays + if [ -x $MDADM ]; then + for raidmod in `$MDADM --detail --scan|awk '{print $3}'|awk -F '=' '{print $2}'`; do + case "$raidmod" in + linear|raid[015]) + FindModule "$raidmod" + ;; + *) + echo "raid level $raidmod (in output of mdadm) not recognized" >&2 + ;; + esac + done + fi + +#### and just for perfection: allow to _manually_ specify raid level, even if it is not running now. + case "$FORCE_RAID" in + [015]) + FindModule "raid$FORCE_RAID" + ;; + 4) + FindModule "raid5" + ;; + -1|linear) + FindModule "linear" + ;; + *) + echo "raid level $FORCE_RAID (in --force-raid) not recognized" >&2 + ;; + esac fi if grep -s '^/dev/ataraid' "$FSTAB_FILE" |fgrep -qsv noauto; then @@ -589,13 +637,18 @@ [ -n "$1" ] && Exit "$1" || Exit } -TEMP=`getopt -n "$PROG" -o fhvd -l help,version,verbose,debug,force,ifneeded,omit-scsi-modules,omit-ide-modules,omit-raid-modules,pause,image-version,nocompress,nobootsplash,strict,fstab:,before:,preload:,with:,after: -- "$@"` || Usage 1 +TEMP=`getopt -n "$PROG" -o fhvd -l help,version,verbose,debug,force,ifneeded,omit-scsi-modules,omit-ide-modules,omit-raid-modules,pause,image-version,nocompress,nobootsplash,strict,fstab:,before:,preload:,with:,after:,force-raid: -- "$@"` || Usage 1 eval set -- "$TEMP" img_vers= force= while :; do case "$1" in + --force-raid) + shift + FORCE_RAID=$1 + shift + ;; --fstab) shift FSTAB_FILE=$1