]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
Make root=/dev/XYZ work with grub, too.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 16 Sep 2004 16:50:22 +0000 (16:50 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Thu, 16 Sep 2004 16:50:22 +0000 (16:50 +0000)
svn-id: @4600

geninitrd

index a0ce1ad6d766fe26fd2da422f013c323d9f59cff..34fc898e4d69f8539991bb275be96a765af1b267 100755 (executable)
--- 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"
This page took 0.096662 seconds and 4 git commands to generate.