[readonly/geninitrd: 524/1068] - parse root=/dev/sys/rootfs from kernel commandline for lvm2

draenog draenog at pld-linux.org
Sat Nov 2 19:56:27 CET 2013


commit 6bdc2eebbdd250c6dfa73ce5e807aaf3b36a3ea7
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Tue Nov 13 16:22:41 2007 +0000

    - parse root=/dev/sys/rootfs from kernel commandline for lvm2
    
    svn-id: @9041

 geninitrd | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 2f1d89f..f467ab3 100755
--- a/geninitrd
+++ b/geninitrd
@@ -1314,10 +1314,23 @@ initrd_gen_lvm() {
 		initrd_gen_devices
 
 		add_linuxrc <<-EOF
-			export LVM_ROOTDEV=$rootdev
-			export LVM_VGVOLUME=$VGVOLUME
+			export ROOTDEV=$rootdev
+			export VGVOLUME=$VGVOLUME
 		EOF
 		add_linuxrc <<-'EOF'
+			# parse rootdev from kernel commandline
+			for arg in $CMDLINE; do
+				if [ "${arg##root=}" != "${arg}" ]; then
+					ROOTDEV=${arg##root=}
+					echo "Using $ROOTDEV from kernel commandline"
+					local tmp=${ROOTDEV#/dev/}
+					if [ "$tmp" != "$ROOTDEV" ]; then
+						VGVOLUME=${tmp%/*}
+						echo "Using $VGVOLUME LVM Volume Group from kernel commandline"
+					fi
+				fi
+			done
+
 			# disable noise from LVM accessing devices that aren't ready.
 			read printk < /proc/sys/kernel/printk
 			echo 0 > /proc/sys/kernel/printk
@@ -1327,14 +1340,14 @@ initrd_gen_lvm() {
 			lvm.static vgscan --mknodes --ignorelockingfailure 2>/dev/null
 
 			: 'Activating Volume Groups'
-			lvm.static vgchange --ignorelockingfailure -a y $LVM_VGVOLUME 2>/dev/null
+			lvm.static vgchange --ignorelockingfailure -a y $VGVOLUME 2>/dev/null
 
 			echo "$printk" > /proc/sys/kernel/printk
 
 			# Find out major/minor
-			attrs="$(lvm.static lvdisplay --ignorelockingfailure -c $LVM_ROOTDEV 2>/dev/null)"
+			attrs="$(lvm.static lvdisplay --ignorelockingfailure -c $ROOTDEV 2>/dev/null)"
 			if [ "$attrs" ]; then
-				majmin="${attrs#*$LVM_ROOTDEV*:*:*:*:*:*:*:*:*:*:*:*}"
+				majmin="${attrs#*$ROOTDEV*:*:*:*:*:*:*:*:*:*:*:*}"
 				if [ "$majmin" != "$attrs" ]; then
 					major="${majmin%:*}"
 					minor="${majmin#*:}"
@@ -1345,7 +1358,7 @@ initrd_gen_lvm() {
 				# Pass it to kernel
 				echo $((256 * $major + $minor)) > /proc/sys/kernel/real-root-dev
 			else
-				echo 2>&1 "Error figuring out real root device for $LVM_ROOTDEV!"
+				echo 2>&1 "Error figuring out real root device for $ROOTDEV!"
 				echo 2>&1 "System will not most likely boot up! So dropping you to a shell!"
 				echo 2>&1 ""
 				sh
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list