]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
templates: Add GRUB_CMDLINE_LINUX_RECOVERY
authorChris Vogel <chris@z9.de>
Wed, 15 Sep 2021 15:42:29 +0000 (17:42 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 20 Sep 2021 11:52:55 +0000 (13:52 +0200)
When generating grub.cfg using grub-mkconfig and the scripts 10_linux and
20_linux_xen there is no way to add kernel command line parameters _only_ to
the recovery entries generated.

This is needed to e.g. start a debug shell in installations using systemd
using the kernel command line parameter "systemd.debug-shell" or to recover
in a system with encrypted root in situations where the decryption of the
root filesystem per crypttab in the intiramfs image is broken and the recovery
entry should contain information how to decrypt the rootfs (cryptopts=).

This patch does not change the default behaviour of the GRUB if
GRUB_CMDLINE_LINUX_RECOVERY is not set.

If GRUB_CMDLINE_LINUX_RECOVERY is set and the generated recovery entry should
include the kernel parameter "single" the parameter must be explicitly included
in GRUB_CMDLINE_LINUX_RECOVERY.

As far as I know all credits for the idea and the initial implementation go to
Kyle Ranking of Purism.

Signed-off-by: Kyle Rankin <kyle.rankin@puri.sm>
Signed-off-by: Chris Vogel <chris@z9.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
docs/grub.texi
util/grub-mkconfig.in
util/grub.d/10_linux.in
util/grub.d/20_linux_xen.in

index 0be5003878e141ce4ae00295ed136a16ee91f21a..255a781c2ac3f3f27b41c23d7ee32c6537c44a33 100644 (file)
@@ -1411,6 +1411,13 @@ entry for recovery mode.  This option lists command-line arguments to add
 only to the default menu entry, after those listed in
 @samp{GRUB_CMDLINE_LINUX}.
 
+@item GRUB_CMDLINE_LINUX_RECOVERY
+Unless @samp{GRUB_DISABLE_RECOVERY} is set to @samp{true}, two menu
+entries will be generated for each Linux kernel: one default entry and one
+entry for recovery mode. This option lists command-line arguments to add
+only to the recovery menu entry, before those listed in @samp{GRUB_CMDLINE_LINUX}.
+The default is @samp{single}.
+
 @item GRUB_CMDLINE_NETBSD
 @itemx GRUB_CMDLINE_NETBSD_DEFAULT
 As @samp{GRUB_CMDLINE_LINUX} and @samp{GRUB_CMDLINE_LINUX_DEFAULT}, but for
index f8cbb8d7a2bf487324b27566f9ef1c5c706fee7f..c3ea7612e129c4fe9f23e4a4927cbfcb07bd1c8e 100644 (file)
@@ -225,6 +225,7 @@ export GRUB_DEFAULT \
   GRUB_DISTRIBUTOR \
   GRUB_CMDLINE_LINUX \
   GRUB_CMDLINE_LINUX_DEFAULT \
+  GRUB_CMDLINE_LINUX_RECOVERY \
   GRUB_CMDLINE_XEN \
   GRUB_CMDLINE_XEN_DEFAULT \
   GRUB_CMDLINE_LINUX_XEN_REPLACE \
index e8b01c0d0c71cf1f85d95d73d204e09dc8ad7eba..ca068038ee193732bb4e11d7ef28190fa697789f 100644 (file)
@@ -43,6 +43,10 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+if [ "x${GRUB_CMDLINE_LINUX_RECOVERY}" = "x" ] ; then
+  GRUB_CMDLINE_LINUX_RECOVERY=single
+fi
+
 # Default to disabling partition uuid support to maintian compatibility with
 # older kernels.
 GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
@@ -287,7 +291,7 @@ while [ "x$list" != "x" ] ; do
               "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" recovery \
-                "single ${GRUB_CMDLINE_LINUX}"
+                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
   fi
 
   list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
index 3b1f4704921ee7ff9fd386c5d4cf65a8641746fb..f45559ff8ec61a72735a1e7142f0d4e0f9644103 100644 (file)
@@ -43,6 +43,10 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+if [ "x${GRUB_CMDLINE_LINUX_RECOVERY}" = "x" ] ; then
+  GRUB_CMDLINE_LINUX_RECOVERY=single
+fi
+
 # Default to disabling partition uuid support to maintian compatibility with
 # older kernels.
 GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true}
@@ -343,7 +347,7 @@ while [ "x${xen_list}" != "x" ] ; do
            "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
        if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
            linux_entry "${OS}" "${version}" "${xen_version}" recovery \
-               "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
+               "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
        fi
 
        list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`