From 1157143d67b02ccf95602ae082f6fbfd1a20f342 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Mon, 29 Aug 2022 03:59:49 +0200 Subject: [PATCH] feat(dracut.sh): populate uefi_cmdline if no other cmdline is given When creating uefi image in hostonly mode (with using --hostonly-cmdline), it makes sense to copy current kernel commandline from /proc/cmdline, in case there are no other options specified. Usually, the cmdline.d/*.conf file is generated by module rootfs-block (or other modules), but it might, not handle all cases correctly, and specifying --kernel-cmdline every time is not much user-friendly. --- dracut.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dracut.sh b/dracut.sh index 4f4fb8a0d9..c612a296ae 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2598,14 +2598,18 @@ umask 077 if [[ $uefi == yes ]]; then if [[ $kernel_cmdline ]]; then echo -n "$kernel_cmdline" > "$uefi_outdir/cmdline.txt" - elif [[ $hostonly_cmdline == yes ]] && [ -d "$initdir/etc/cmdline.d" ]; then - for conf in "$initdir"/etc/cmdline.d/*.conf; do - [ -e "$conf" ] || continue - printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt" - done + elif [[ $hostonly_cmdline == yes ]]; then + if [ -d "$initdir/etc/cmdline.d" ]; then + for conf in "$initdir"/etc/cmdline.d/*.conf; do + [ -e "$conf" ] || continue + printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt" + done + elif [ -e "/proc/cmdline" ]; then + printf "%s " "$(< "/proc/cmdline")" > "$uefi_outdir/cmdline.txt" + fi fi - if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -d "$initdir/etc/cmdline.d" ]]; then + if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -e "${uefi_outdir}/cmdline.txt" ]]; then echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" dinfo "Using UEFI kernel cmdline:" dinfo "$(tr -d '\000' < "$uefi_outdir/cmdline.txt")"