From 8a2edb1e4da9e63a8bee2e06b8a1fad9cf31e444 Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Thu, 28 Jan 2021 22:40:59 -0600 Subject: [PATCH] fix: do not set cmdline for uefi images unless asked The kernel does not allow the cmdline to be overridden if one is defined in the uefi image. This means that bootloaders like systemd-boot or grub cannot manage boot options (editing at boot for debug being a use case). This patchset allows for no cmdline to be set (instead of force setting one if none is provided). Fixes: https://github.com/dracutdevs/dracut/issues/1012 Signed-off-by: Matthew Thode --- dracut.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dracut.sh b/dracut.sh index 056a4114c..ea26b6460 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2163,13 +2163,16 @@ if [[ $uefi = yes ]]; then [ -e "$conf" ] || continue printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt" done - else - do_print_cmdline > "$uefi_outdir/cmdline.txt" fi - echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" - dinfo "Using UEFI kernel cmdline:" - dinfo $(tr -d '\000' < "$uefi_outdir/cmdline.txt") + if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline = yes && -d "$initdir/etc/cmdline.d" ]]; then + echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" + dinfo "Using UEFI kernel cmdline:" + dinfo $(tr -d '\000' < "$uefi_outdir/cmdline.txt") + uefi_cmdline="--add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000" + else + uefi_cmdline="" + fi [[ -s $dracutsysrootdir/usr/lib/os-release ]] && uefi_osrelease="$dracutsysrootdir/usr/lib/os-release" [[ -s $dracutsysrootdir/etc/os-release ]] && uefi_osrelease="$dracutsysrootdir/etc/os-release" @@ -2178,7 +2181,7 @@ if [[ $uefi = yes ]]; then if objcopy \ ${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \ - --add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000 \ + ${uefi_cmdline} \ ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \ --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \ --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \ -- 2.47.3