View | Details | Raw Unified | Return to bug 5955
Collapse All | Expand All

(-)mkinitrd.orig (-11 / +98 lines)
Lines 134-139 Link Here
134
noscsi=
134
noscsi=
135
noide=
135
noide=
136
noraid=
136
noraid=
137
nomdadm=
138
noraidtab=
137
pause=
139
pause=
138
MODULES=
140
MODULES=
139
MODULES_DIR=
141
MODULES_DIR=
Lines 643-652 Link Here
643
		[0156])
645
		[0156])
644
			FindModule "raid$level"
646
			FindModule "raid$level"
645
			;;
647
			;;
646
		4)
648
		4|raid4)
647
			FindModule "raid5"
649
			FindModule "raid5"
648
			;;
650
			;;
649
		-1|linear)
651
		linear|multipath|raid[0156])
652
			FindModule $level
653
			;;
654
		-1)
650
			FindModule "linear"
655
			FindModule "linear"
651
			;;
656
			;;
652
		*)
657
		*)
Lines 661-666 Link Here
661
		awk '{print $2}' | LC_COLLATE=C sort -u
666
		awk '{print $2}' | LC_COLLATE=C sort -u
662
}
667
}
663
668
669
     MDADM=/usr/sbin/mdadm
670
MDASSEMBLE=/sbin/mdassemble
671
MDADM_CONF=/etc/mdadm.conf
672
  MDDEVNUM=9
673
674
mddev()	# $1 = device to check => raiddevices, nonraiddevices (currently not used), stacked_md
675
{
676
    local -i major
677
    local dev md
678
    local stack=${2-0}
679
    : ${stacked_md=0}
680
    major=$((0x$(stat -L -c '%t' $1)))
681
    if [ $major = $MDDEVNUM ]; then
682
	# need to reverse the raiddevices list to account for stacked md devices
683
	raiddevices="$1 $raiddevices"
684
	md=${1##*/}
685
	md=md${md#md} # /dev/md/0 and /dev/md0 become md0
686
	mddevs=$(awk '/^'$md'[[:space:]]*:/ {for (i=5;i<=NF;i++) {sub("\\[[0-9]*\\]","",$i); print "/dev/" $i } }' /proc/mdstat) #'
687
	[ -n "$mddevs" ] && stack=$(($stack + 1))
688
	[ $stack -gt $stacked_md ] && stacked_md=$stack
689
	for dev in $mddevs; do
690
	    mddev $dev $stack
691
	done
692
    else
693
	nonraiddevices="$nonraiddevices $1"
694
    fi
695
}
696
697
FindRaidModulesFromMdadm()
698
{
699
	mddev $rootdev
700
	for md in $raiddevices; do
701
		md=${md##*/}
702
		md=md${md#md} # /dev/md/0 and /dev/md0 become md0
703
		level=$(awk '/^'$md'[[:space:]]*:/ { print $4 }' /proc/mdstat)
704
		FindRaidModuleForLevel $level
705
	done
706
}
707
664
FindRaidModules()
708
FindRaidModules()
665
{
709
{
666
	[ -z "$noraid" ] || return
710
	[ -z "$noraid" ] || return
Lines 672-680 Link Here
672
716
673
	if [ -n "$HAVE_RAID" ]; then
717
	if [ -n "$HAVE_RAID" ]; then
674
		FindModule -md
718
		FindModule -md
675
		if [ -r /etc/raidtab ]; then
719
		if [ -z "$nomdadm" -a -r $MDADM_CONF ]; then
720
			FindRaidModulesFromMdadm
721
			noraidtab=1
722
		fi
723
		if [ -z "$noraidtab" -a -r /etc/raidtab ]; then
676
			for number in `ListRaidLevelsFromRaidtab`; do
724
			for number in `ListRaidLevelsFromRaidtab`; do
677
				FindRaidModuleForLevel "$number"
725
				FindRaidModuleForLevel "$number"
726
				stacked_md=1
678
			done
727
			done
679
		fi
728
		fi
680
	fi
729
	fi
Lines 695-701 Link Here
695
FindRootModules()
744
FindRootModules()
696
{
745
{
697
	# In case the root filesystem is modular.
746
	# In case the root filesystem is modular.
698
	#rootdev=$(awk '{if (($2 == "/") && ($1 !~ /^[ \t]*#/) {print $1}}' "$FSTAB_FILE")
747
	rootdev=$(awk '{if (($2 == "/") && ($1 !~ /^[ \t]*#/)) {print $1}}' "$FSTAB_FILE")
699
	local rootfs
748
	local rootfs
700
	rootfs=$(awk '{if (($2 == "/") && ($1 !~ /^[ \t]*#/)) {print $3}}' "$FSTAB_FILE")
749
	rootfs=$(awk '{if (($2 == "/") && ($1 !~ /^[ \t]*#/)) {print $3}}' "$FSTAB_FILE")
701
	[ -z "$rootfs" ] || FindModule -"$rootfs"
750
	[ -z "$rootfs" ] || FindModule -"$rootfs"
Lines 753-758 Link Here
753
		Fatal "Failed to create \"$file\" device."
802
		Fatal "Failed to create \"$file\" device."
754
}
803
}
755
804
805
ActivateMdDevices()
806
{
807
	echo "echo Create RAID devices" >> $RCFILE
808
	[ -x $MDADM ] && echo "DEVICE partitions" >| ${MNTIMAGE}$MDADM_CONF
809
	for dev in $raiddevices; do
810
		md=${dev##*/}
811
		md=${md#md} # /dev/md/0 and /dev/md0 become 0
812
		echo "mknod /safedev/md${md} b $MDDEVNUM ${md}" >> $RCFILE
813
		if [ -x $MDADM ]; then
814
			$MDADM -D -b $dev | grep '^ARRAY' \
815
			| sed -e 's,\/dev\/,\/safedev\/,g' \
816
			>> ${MNTIMAGE}$MDADM_CONF
817
    		fi
818
	done
819
	if [ -x $MDASSEMBLE ]; then
820
		Cp -aL $MDASSEMBLE $MNTIMAGE/sbin/
821
		raidstart_command="mdassemble"
822
	elif [ -x $MDADM ]; then
823
		Cp -aL $MDADM $MNTIMAGE/sbin/
824
		raidstart_command="mdadm -A -s"
825
	else
826
		Ln -s sh "$MNTDIR/bin/raidautorun"
827
		Mknod "$MNTDIR/safedev/md255" b 9 255
828
		raidstart_command="raidautorun /safedev/md255"
829
	fi
830
	echo "echo Activate RAID devices" >> $RCFILE
831
	while [ $stacked_md -gt 0 ]; do
832
		echo $raidstart_command >> $RCFILE
833
		stacked_md=$(($stacked_md - 1))
834
	done
835
}
836
756
MakeMountDir()
837
MakeMountDir()
757
{
838
{
758
	MNTDIR="$WORKDIR/tree"
839
	MNTDIR="$WORKDIR/tree"
Lines 807-817 Link Here
807
	done
888
	done
808
889
809
	if [ -n "$HAVE_RAID" ]; then
890
	if [ -n "$HAVE_RAID" ]; then
810
		Mknod "$MNTDIR/safedev/md255" b 9 255
891
		ActivateMdDevices
811
		Ln -s sh "$MNTDIR/bin/raidautorun"
812
		cat >>"$RCFILE" <<EOF
813
/bin/raidautorun /safedev/md255
814
EOF
815
	fi
892
	fi
816
893
817
	if [ -n "$loopDev" ]; then
894
	if [ -n "$loopDev" ]; then
Lines 967-972 Link Here
967
--omit-scsi-modules             do not load any SCSI modules.
1044
--omit-scsi-modules             do not load any SCSI modules.
968
--omit-ide-modules              do not load any IDE modules.
1045
--omit-ide-modules              do not load any IDE modules.
969
--omit-raid-modules             do not load any raid modules.
1046
--omit-raid-modules             do not load any raid modules.
1047
--omit-mdadm                    skip /etc/mdadm.conf, but check /etc/raidtab
1048
--omit-raidtab                  skip /etc/raidtab, but check /etc/mdadm.conf
970
--pause                         pause for manual initrd editing.
1049
--pause                         pause for manual initrd editing.
971
--nocompress                    do not compress initrd image.
1050
--nocompress                    do not compress initrd image.
972
--nobootsplash                  do not add bootsplash to the initrd image.
1051
--nobootsplash                  do not add bootsplash to the initrd image.
Lines 1035-1040 Link Here
1035
			noraid=1
1114
			noraid=1
1036
			shift
1115
			shift
1037
			;;
1116
			;;
1117
		--omit-mdadm)
1118
			nomdadm=1
1119
			shift
1120
			;;
1121
		--omit-raidtab)
1122
			noraidtab=1
1123
			shift
1124
			;;
1038
		--with-raid)
1125
		--with-raid)
1039
			HAVE_RAID=1
1126
			HAVE_RAID=1
1040
			shift
1127
			shift
Lines 1116-1125 Link Here
1116
1203
1117
FindScsiModules
1204
FindScsiModules
1118
1205
1119
FindRaidModules
1120
1121
FindRootModules
1206
FindRootModules
1122
1207
1208
FindRaidModules
1209
1123
FindLoopModules
1210
FindLoopModules
1124
1211
1125
FindModules $POSTLOAD_MODNAMES
1212
FindModules $POSTLOAD_MODNAMES

Return to bug 5955