[readonly/geninitrd/devel: 238/334] Make root=/dev/XYZ work with grub, too.

draenog draenog at pld-linux.org
Sat Nov 2 19:31:32 CET 2013


commit 2b1a3707206b3469d640b346f0fe119e09781c5a
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Sep 16 16:50:22 2004 +0000

    Make root=/dev/XYZ work with grub, too.
    
    svn-id: @4600

 geninitrd | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index a0ce1ad..34fc898 100755
--- a/geninitrd
+++ b/geninitrd
@@ -1027,15 +1027,16 @@ initrd_gen_suspend() {
 	modules_install "$MODULES"
     	mkdir -p $MNTIMAGE/sys
     	mkdir -p $MNTIMAGE/proc
-	echo "mount -t proc none /proc" >> "$s"
-	echo "cmdline=\`cat /proc/cmdline\`" >> "$s"
-	echo "if [ \"\$cmdline\" != \"\${cmdline#* resume2=}\" ]; then" >> "$s"
+cat << EOF >> "$s"
+mount -t proc none /proc
+if [ "\$(awk ' /resume2=/  { print "yes"; } ' /proc/cmdline)" = "yes" ]; then
+EOF
 	modules_add_linuxrc "$MODULES" "$s"
-	echo "	echo > /proc/software_suspend/activate" >> "$s"
-	echo "  umount /proc" >> "$s"
-	echo "	exit 0" >> "$s"
-	echo "fi" >> "$s"
-	echo "umount /proc" >> "$s"
+cat << EOF >> "$s"
+		echo > /proc/software_suspend/activate
+fi
+umount /proc
+EOF
 }
 
 initrd_gen_softraid() {
@@ -1186,6 +1187,24 @@ initrd_gen_lvm() {
 	fi
 }
 
+initrd_gen_procdata() {
+    	[ -n "$verbose" ] && echo "Adding rootfs finding based on root= option support."
+	mkdir -p $MNTIMAGE/proc
+cat << EOF >> "$s"
+set +x
+mount -t proc none /proc
+root="\$(busybox awk ' /root=\/dev\// { gsub(/.*root=\/dev\//,NIL,\$0); gsub(/ .*/,NIL,\$0); print \$0; } ' /proc/cmdline)"
+if [ -n "\$root" ]; then
+    rootnr="\$(busybox awk -v root="\$root" ' { if (\$4 == root) { print 256*\$1+\$2; } } ' /proc/partitions)"
+    if [ -n "\$rootnr" ]; then
+	echo "\$rootnr" > /proc/sys/kernel/real-root-dev
+    fi
+fi
+echo "umount /proc"
+set -x
+EOF
+}
+
 # main generation
 if is_yes "$USESUSPEND"; then
 	initrd_gen_suspend
@@ -1200,6 +1219,8 @@ elif is_yes "$USERAIDSTART" && is_yes "$raidfound" ; then
 	fi
 elif is_yes "$uselvm" ; then
 	initrd_gen_lvm
+else
+	initrd_gen_procdata
 fi
 
 chmod +x "$RCFILE"
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list