Skip to content

Commit

Permalink
feat(dracut.sh): populate uefi_cmdline if no other cmdline is given
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pvalena authored and johannbg committed Sep 26, 2022
1 parent 23684e4 commit 1157143
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")"
Expand Down

0 comments on commit 1157143

Please sign in to comment.