[readonly/geninitrd/devel: 196/334] Support for LVM on top of SoftRAID.

draenog draenog at pld-linux.org
Sat Nov 2 19:28:00 CET 2013


commit 4e9eb79c042ac2023b3f979dc6605971aa99edf1
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Apr 2 22:09:37 2004 +0000

    Support for LVM on top of SoftRAID.
    
    svn-id: @3861

 geninitrd | 69 +++++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 47 insertions(+), 22 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 68820d3..e425704 100755
--- a/geninitrd
+++ b/geninitrd
@@ -2,7 +2,7 @@
 
 # geninitrd
 #
-#	by Jacek Konieczny <jajcus at pld.org.pl>
+#	by Jacek Konieczny <jajcus at pld-linux.org>
 #
 # based on mkinitrd from RedHat
 
@@ -36,6 +36,7 @@ raidtab="/etc/raidtab"
 fstab="/etc/fstab"
 insmod="insmod"
 modext=".o"
+rootdev_nr=0
 # default bootsplash is off, if it have to be on, install bootsplash package
 BOOT_SPLASH=no
 
@@ -312,7 +313,7 @@ find_root() {
 		fi
 		;;
 	esac
-
+	rootdev1=${rootdev}
 }
 
 find_modules_softraid() {
@@ -407,6 +408,11 @@ END {
 			;;
 		esac
 	fi
+
+	rootdev_nr=$(( $rootdev_nr + 1 ))
+	eval "rootdev${rootdev_nr}=\"$1\""
+	eval "dev_list${rootdev_nr}=\"${dev_list}\""
+	
 	for device in $dev_list; do
 		find_modules_for $device
 	done
@@ -535,7 +541,10 @@ END {
 }
 
 find_modules_for() {
-	if is_yes "`echo "$1" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
+        if [ -z "$1" ]; then
+	    	echo "ERROR: no argument passed to find_modules_for()" >&2
+		exit
+	elif is_yes "`echo "$1" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
 		find_modules_softraid "$1"
 	elif is_yes "$(echo "$1" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
 		find_modules_scsi
@@ -585,7 +594,7 @@ find_modules_for() {
 		findmodule "-$loopFs"
 		BASICMODULES="$BASICMODULES -${loopFs}"
 		# don't have any clue, how is this supposed to work
-	elif ls -l "$1" | awk '{if (/^b/) { if ($5 == "58,") { exit 0; } else { exit 1; } } else { exit 1; }}' || /sbin/lvdisplay "$1" > /dev/null 2>&1 ; then
+	elif ls -l "$1" 2> /dev/null | awk '{if (/^b/) { if ($5 == "58,") { exit 0; } else { exit 1; } } else { exit 1; }}' || /sbin/lvdisplay "$1" > /dev/null 2>&1 ; then
 		if [ ! -f /sbin/initrd-lvm -o ! -x /sbin/lvdisplay -o ! -x /sbin/pvdisplay ] ; then
 			echo "ERROR: root on LVM but /sbin/initrd-lvm, /sbin/lvdisplay and /sbin/pvdisplay not found." >&2
 			echo "Please install lvm(2) and lvm(2)-initrd package and rerun $0." >&2
@@ -841,7 +850,7 @@ fi
 
 find_root
 
-find_modules_for "$rootdev"
+find_modules_for "$rootdev1"
 
 findmodule "-$rootFs"
 
@@ -943,22 +952,22 @@ for MODULE in $MODULES; do
 	echo "$insmod /lib/modules/$kernel/$MODULE2 $options" >> "$s"
 done
 
-# TODO: rewrite for bsp
+# TODO: rewrite for busybox
 #if [ -n "$loopDev" ]; then
 #	if [ ! -d /initrd ]; then
 #		mkdir /initrd
 #	fi
 #
 #	cp -a "$loopDev" "$MNTIMAGE/dev"
-#	cp -a "$rootdev" "$MNTIMAGE/dev"
+#	cp -a "$rootdev1" "$MNTIMAGE/dev"
 #	echo "echo Mounting device containing loopback root filesystem" >> "$RCFILE"
 #	echo "mount -t $loopFs $loopDev /loopfs" >> "$RCFILE"
-#	echo "echo Setting up loopback device $rootdev" >> $RCFILE
-#	echo "losetup $rootdev /loopfs$loopFile" >> "$RCFILE"
+#	echo "echo Setting up loopback device $rootdev1" >> $RCFILE
+#	echo "losetup $rootdev1 /loopfs$loopFile" >> "$RCFILE"
 #fi
 
 if is_yes "$USERAIDSTART" && is_yes "$raidfound" ; then
-	[ -n "$verbose" ] && echo "Setting up mdadm ($rootdev $dev_list)"
+	[ -n "$verbose" ] && echo "Setting up mdadm..."
 	
 	if [ ! -x /sbin/initrd-mdadm -a ! -x /sbin/initrd-mdassemble ] ; then
 	    	echo "/sbin/initrd-mdadm and /sbin/initrd-mdassemble are missing !"
@@ -966,27 +975,43 @@ if is_yes "$USERAIDSTART" && is_yes "$raidfound" ; then
 	fi
 
 	if [ -x /sbin/initrd-mdassemble ] ; then
+    	    do_mdasseble=1
 	    inst /sbin/initrd-mdassemble "$MNTIMAGE/bin/mdassemble"
-	    echo "DEVICE $dev_list" > "$MNTIMAGE/etc/mdadm.conf"
-	    echo "ARRAY $rootdev" >> "$MNTIMAGE/etc/mdadm.conf"
-	    echo "mdassemble" >> "$s"
 	else
-    	    inst /sbin/initrd-mdadm "$MNTIMAGE/bin/mdadm"
-    	    echo "mdadm --assemble $rootdev $dev_list" >> "$s"
-	fi
-
-	# needed to determine md-version
-	if [ "$rootdev" != /dev/md0 ] ; then
-		mknod $MNTIMAGE/dev/md0 b 9 0
+	    do_mdassemble=0
+	    inst /sbin/initrd-mdadm "$MNTIMAGE/bin/mdadm"
 	fi
-	
-	for f in $dev_list $rootdev ; do
+	    
+	# LVM on RAID case
+        do_md0=1
+	for nr in `seq 1 $rootdev_nr`; do
+	    eval cr_rootdev="\$rootdev${nr}"
+	    eval cr_dev_list="\$dev_list${nr}"
+	    [ -n "$verbose" ] && echo "Setting up array ($cr_rootdev = $cr_dev_list)"
+
+	    [ "$cr_rootdev" = "/dev/md0" ] && do_md0=0
+	    
+	    if [ "$do_mdassemble" -eq 1 ] ; then
+	    	echo "DEVICE $cr_dev_list" >> "$MNTIMAGE/etc/mdadm.conf"
+	    	echo "ARRAY $cr_rootdev" >> "$MNTIMAGE/etc/mdadm.conf"
+	    	echo "mdassemble" >> "$s"
+    	    else
+    		echo "mdadm --assemble $cr_rootdev $cr_dev_list" >> "$s"
+    	    fi
+
+	    for f in $cr_dev_list $cr_rootdev ; do
 		# mkdir in case of devfs name
 		mkdir -p $MNTIMAGE/`my_dirname $f`
 		[ -n "$verbose" ] && echo "copying $f"
 		# this works fine with and without devfs
 		cp -HR $f $MNTIMAGE/$f
+	    done
 	done
+
+	# needed to determine md-version
+	if [ "$do_md0" -eq 1 ] ; then
+		mknod $MNTIMAGE/dev/md0 b 9 0
+	fi
 fi
 
 if is_yes "$uselvm" ; then
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/398807324938659207036e520c0950a61ef50c11



More information about the pld-cvs-commit mailing list