From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mQX3g-0005SC-4Z for mharc-grub-devel@gnu.org; Wed, 15 Sep 2021 11:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQX3e-0005P5-Ji for grub-devel@gnu.org; Wed, 15 Sep 2021 11:42:46 -0400 Received: from mx.link-goe.de ([185.199.217.181]:39603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQX3a-0005FZ-S1 for grub-devel@gnu.org; Wed, 15 Sep 2021 11:42:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ween.de; s=mx; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To: From:Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=SWFaS4HyMiig8wiZLVk70gdwbFbbQ/cvzYF18AlIJP4=; b=Y C3t937ER+xGrCEGsU5mb2TaSWesgey/rdx7hd5rWAEX+k6g6JaE/5VMIyXq7MRkOdIrgTSJMMLObN Thu4XjZ+kxj7N9GRVk9O9hnXtfpGZ3adB+f4D8nEPluQg+i/4Lb+3dO/Oel5qEj48dcuAxphIVU5J u+sqUgjp1TRKjtPw=; From: chris@z9.de To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, alexander.burmashev@oracle.com, phcoder@gmail.com, kyle.rankin@puri.sm, Chris Vogel Subject: [PATCH] templates: Add GRUB_CMDLINE_LINUX_RECOVERY Date: Wed, 15 Sep 2021 17:42:29 +0200 Message-Id: <20210915154229.64650-1-chris@z9.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.199.217.181; envelope-from=chris@z9.de; helo=mx.link-goe.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 15:42:47 -0000 From: Chris Vogel 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 informations about how to decrypt the rootfs (cryptopts=). This patch does not change the default behaviour of 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: Chris Vogel --- docs/grub.texi | 8 ++++++++ util/grub-mkconfig.in | 1 + util/grub.d/10_linux.in | 6 +++++- util/grub.d/20_linux_xen.in | 6 +++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index f8b4b3b21..8b5482ee1 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1411,6 +1411,14 @@ 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 diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index f8cbb8d7a..c3ea7612e 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -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 \ diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index e8b01c0d0..af51ae2f7 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -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' ' '` diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 3b1f47049..992363c3e 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -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' ' '` -- 2.30.2