2012-08-31 09:28:14 +02:00
|
|
|
From 340fd0c8717c2bf33163a18bfec72243b0e51862 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Michael Chang <mchang@suse.com>
|
|
|
|
Date: Thu, 30 Aug 2012 15:43:17 +0800
|
|
|
|
Subject: [PATCH] Pass corret root= for nfsroot
|
|
|
|
|
2017-12-11 05:47:09 +01:00
|
|
|
References: bnc#774548, bsc#1069094
|
2012-08-31 09:28:14 +02:00
|
|
|
Patch-Mainline: no
|
|
|
|
|
|
|
|
Fix / is mounted on nfs. The fix is to pass kernel parameters
|
|
|
|
with correct root= for nfs. However since grub2 doesn't support
|
|
|
|
nfs file system module, the /boot on nfs is not possible and
|
|
|
|
grub2-probe not work in probing nfs mounted path. The fix is merely
|
|
|
|
on the script level and not use grub2-probe for above reasons.
|
2017-12-11 05:47:09 +01:00
|
|
|
|
|
|
|
v2: Filter out autofs and securityfs from /proc/self/mountinfo (bsc#1069094)
|
|
|
|
|
2012-08-31 09:28:14 +02:00
|
|
|
---
|
|
|
|
util/grub-mkconfig.in | 37 ++++++++++++++++++++++++++++++-------
|
|
|
|
1 files changed, 30 insertions(+), 7 deletions(-)
|
|
|
|
|
2021-07-08 11:03:14 +02:00
|
|
|
Index: grub-2.06~rc1/util/grub-mkconfig.in
|
2014-01-06 04:50:43 +01:00
|
|
|
===================================================================
|
2021-07-08 11:03:14 +02:00
|
|
|
--- grub-2.06~rc1.orig/util/grub-mkconfig.in
|
|
|
|
+++ grub-2.06~rc1/util/grub-mkconfig.in
|
|
|
|
@@ -131,14 +131,27 @@ else
|
2012-08-31 09:28:14 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
-# Device containing our userland. Typically used for root= parameter.
|
|
|
|
-GRUB_DEVICE="`${grub_probe} --target=device /`"
|
|
|
|
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
|
2019-10-18 12:18:53 +02:00
|
|
|
-GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true
|
2012-08-31 09:28:14 +02:00
|
|
|
+probe_nfsroot_device () {
|
|
|
|
+ while read line ; do
|
2015-04-13 19:58:16 +02:00
|
|
|
+ part1=`echo $line | sed -e 's! - .*$!!'`
|
|
|
|
+ part2=`echo $line | sed -n -e 's! - \(.*\)$!\n\1!p' | sed 1d`
|
2021-07-08 11:03:14 +02:00
|
|
|
+
|
2015-04-13 19:58:16 +02:00
|
|
|
+ set -- $part1
|
|
|
|
+ path=$5
|
|
|
|
+
|
|
|
|
+ set -- $part2
|
|
|
|
+ fstype=$1
|
|
|
|
+ device=$2
|
|
|
|
+
|
2012-08-31 09:28:14 +02:00
|
|
|
+ if [ "x${path}" = "x/" ] &&
|
|
|
|
+ [ "x${fstype}" = "xnfs" -o "x${fstype}" = "xnfs4" ] ; then
|
2015-04-13 19:58:16 +02:00
|
|
|
+ echo "${fstype}:$device"
|
2012-08-31 09:28:14 +02:00
|
|
|
+ return
|
|
|
|
+ fi
|
|
|
|
+ done
|
2017-12-11 05:47:09 +01:00
|
|
|
+}
|
2021-07-08 11:03:14 +02:00
|
|
|
|
|
|
|
-# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
|
|
|
|
-GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
|
|
|
|
-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
|
2017-12-11 05:47:09 +01:00
|
|
|
+NFSROOT_DEVICE="`awk '($9!="autofs")&&($9!="securityfs")' /proc/self/mountinfo | probe_nfsroot_device`"
|
2015-04-13 19:58:16 +02:00
|
|
|
|
2021-07-08 11:03:14 +02:00
|
|
|
# Disable os-prober by default due to security reasons.
|
|
|
|
GRUB_DISABLE_OS_PROBER="true"
|
|
|
|
@@ -146,11 +159,26 @@ GRUB_DISABLE_OS_PROBER="true"
|
2019-10-18 12:18:53 +02:00
|
|
|
# Filesystem for the device containing our userland. Used for stuff like
|
|
|
|
# choosing Hurd filesystem module.
|
|
|
|
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
|
2021-07-08 11:03:14 +02:00
|
|
|
-
|
|
|
|
-if [ x"$GRUB_FS" = xunknown ]; then
|
|
|
|
- GRUB_FS="$(stat -f -c %T / || echo unknown)"
|
2012-08-31 09:28:14 +02:00
|
|
|
+if [ "x${NFSROOT_DEVICE}" != "x" ]; then
|
2015-04-13 19:58:16 +02:00
|
|
|
+ GRUB_DEVICE=""
|
2012-08-31 09:28:14 +02:00
|
|
|
+ GRUB_DEVICE_UUID=""
|
2019-10-18 12:18:53 +02:00
|
|
|
+ GRUB_DEVICE_PARTUUID=""
|
2012-08-31 09:28:14 +02:00
|
|
|
+ GRUB_FS="unknown"
|
|
|
|
+else
|
|
|
|
+ # Device containing our userland. Typically used for root= parameter.
|
|
|
|
+ GRUB_DEVICE="`${grub_probe} --target=device /`"
|
|
|
|
+ GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
|
2019-10-18 12:18:53 +02:00
|
|
|
+ GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true
|
2021-07-08 11:03:14 +02:00
|
|
|
+
|
2014-01-06 04:50:43 +01:00
|
|
|
+ if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then
|
2019-10-18 12:18:53 +02:00
|
|
|
+ GRUB_FS="$(stat -f -c %T / || echo unknown)"
|
2014-01-06 04:50:43 +01:00
|
|
|
+ fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
+# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
|
|
|
|
+GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
|
|
|
|
+GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
|
|
|
|
+
|
2019-10-18 12:18:53 +02:00
|
|
|
# Provide a default set of stock linux early initrd images.
|
|
|
|
# Define here so the list can be modified in the sourced config file.
|
|
|
|
if [ "x${GRUB_EARLY_INITRD_LINUX_STOCK}" = "x" ]; then
|
2021-07-08 11:03:14 +02:00
|
|
|
Index: grub-2.06~rc1/util/grub.d/10_linux.in
|
2015-04-13 19:58:16 +02:00
|
|
|
===================================================================
|
2021-07-08 11:03:14 +02:00
|
|
|
--- grub-2.06~rc1.orig/util/grub.d/10_linux.in
|
|
|
|
+++ grub-2.06~rc1/util/grub.d/10_linux.in
|
2019-10-18 12:18:53 +02:00
|
|
|
@@ -86,6 +86,12 @@ linux_entry ()
|
2015-04-13 19:58:16 +02:00
|
|
|
type="$3"
|
|
|
|
args="$4"
|
|
|
|
|
|
|
|
+ if [ -n "${linux_root_device_thisversion}" ]; then
|
|
|
|
+ root_device="root=${linux_root_device_thisversion}"
|
|
|
|
+ else
|
|
|
|
+ root_device=""
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
if [ -z "$boot_device_id" ]; then
|
|
|
|
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
|
|
|
fi
|
2019-10-18 12:18:53 +02:00
|
|
|
@@ -141,7 +147,7 @@ linux_entry ()
|
2015-04-13 19:58:16 +02:00
|
|
|
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
|
|
|
sed "s/^/$submenu_indentation/" << EOF
|
|
|
|
echo '$(echo "$message" | grub_quote)'
|
|
|
|
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}
|
|
|
|
+ linux ${rel_dirname}/${basename} ${root_device} ${args}
|
|
|
|
EOF
|
|
|
|
if test -n "${initrd}" ; then
|
|
|
|
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
|
2021-07-08 11:03:14 +02:00
|
|
|
Index: grub-2.06~rc1/util/grub.d/20_linux_xen.in
|
2015-04-13 19:58:16 +02:00
|
|
|
===================================================================
|
2021-07-08 11:03:14 +02:00
|
|
|
--- grub-2.06~rc1.orig/util/grub.d/20_linux_xen.in
|
|
|
|
+++ grub-2.06~rc1/util/grub.d/20_linux_xen.in
|
|
|
|
@@ -107,6 +107,11 @@ linux_entry_xsm ()
|
2015-04-13 19:58:16 +02:00
|
|
|
args="$5"
|
|
|
|
xen_args="$6"
|
2021-07-08 11:03:14 +02:00
|
|
|
xsm="$7"
|
2015-04-13 19:58:16 +02:00
|
|
|
+ if [ -n "${linux_root_device_thisversion}" ]; then
|
|
|
|
+ root_device="root=${linux_root_device_thisversion}"
|
|
|
|
+ else
|
|
|
|
+ root_device=""
|
|
|
|
+ fi
|
2021-07-08 11:03:14 +02:00
|
|
|
# If user wants to enable XSM support, make sure there's
|
|
|
|
# corresponding policy file.
|
|
|
|
if ${xsm} ; then
|
|
|
|
@@ -157,7 +162,7 @@ linux_entry_xsm ()
|
2015-04-13 19:58:16 +02:00
|
|
|
fi
|
2019-10-18 12:18:53 +02:00
|
|
|
${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
|
2015-04-13 19:58:16 +02:00
|
|
|
echo '$(echo "$lmessage" | grub_quote)'
|
2019-10-18 12:18:53 +02:00
|
|
|
- ${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ${args}
|
|
|
|
+ ${module_loader} ${rel_dirname}/${basename} placeholder ${root_device} ${args}
|
2015-04-13 19:58:16 +02:00
|
|
|
EOF
|
|
|
|
if test -n "${initrd}" ; then
|
|
|
|
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
|