From ee96b11faf29c1fa52d919ff7b2ab5424daee5a6 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 17 Dec 2021 15:01:07 +0100 Subject: [PATCH] stages/grub2: ability to not write kernel cmdline Currently we always write the kernel command line to the `grubenv` file, if only to include the root device. Starting with Fedora 33 and thus RHEL 9, the kernel command line included statically in the BLS snippets and the grubenv `kernelopts` variable not used. Instead one of the {/usr/lib,/etc}/kernel/cmdline files is read and the parameters in them used during the creation of the BLS snippets. Therefore we add a new `write_cmdline` option that, if set to FALSE, will prevent us from writing the kernel command line. --- stages/org.osbuild.grub2 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/stages/org.osbuild.grub2 b/stages/org.osbuild.grub2 index b7b21d36..140e592b 100755 --- a/stages/org.osbuild.grub2 +++ b/stages/org.osbuild.grub2 @@ -171,6 +171,11 @@ SCHEMA = """ "type": "boolean", "default": true }, + "write_cmdline": { + "description": "Include the kernel command line in `grubenv`", + "type": "boolean", + "default": true + }, "ignition": { "description": "Include ignition support in the grub.cfg", "type": "boolean", @@ -468,13 +473,14 @@ class GrubConfig: return data -#pylint: disable=too-many-statements +#pylint: disable=too-many-statements,too-many-branches def main(tree, options): root_fs = options.get("rootfs") boot_fs = options.get("bootfs") kernel_opts = options.get("kernel_opts", "") legacy = options.get("legacy", None) uefi = options.get("uefi", None) + write_cmdline = options.get("write_cmdline", True) write_defaults = options.get("write_defaults", True) ignition = options.get("ignition", False) saved_entry = options.get("saved_entry") @@ -528,10 +534,10 @@ def main(tree, options): with open(grubenv, "w") as env: fs_type, fs_id = fs_spec_decode(root_fs) - data = ( - "# GRUB Environment Block\n" - f"kernelopts=root={fs_type}={fs_id} {kernel_opts}\n" - ) + data = "# GRUB Environment Block\n" + + if write_cmdline: + data += f"kernelopts=root={fs_type}={fs_id} {kernel_opts}\n" if saved_entry: data += f"saved_entry={saved_entry}\n"