]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: do not require non-empty kernel cmdline
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Aug 2019 09:34:45 +0000 (11:34 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Aug 2019 16:30:49 +0000 (18:30 +0200)
When booting with Fedora-Server-dvd-x86_64-30-20190411.n.0.iso,
/proc/cmdline is empty (libvirt, qemu host with bios, not sure if that
matters), after installation to disk, anaconda would "crash" in kernel-core
%posttrans, after calling kernel-install, because dracut would fail
with

> Could not determine the kernel command line parameters.
> Please specify the kernel command line in /etc/kernel/cmdline!

I guess it's legitimate, even if unusual, to have no cmdline parameters.
Two changes are done in this patch:

1. do not fail if the cmdline is empty.
2. if /usr/lib/kernel/cmdline or /etc/kernel/cmdline are present, but
   empty, ignore /proc/cmdline. If there's explicit configuration to
   have empty cmdline, don't ignore it.

The same change was done in dracut:
https://github.com/dracutdevs/dracut/pull/561.

src/kernel-install/90-loaderentry.install

index 2fb0f5207b3339e1ee13d62f52582c50a531b08d..47a0cd224ae8518ba56732305604eec3c521d462 100644 (file)
@@ -45,13 +45,13 @@ if ! [[ $PRETTY_NAME ]]; then
     PRETTY_NAME="Linux $KERNEL_VERSION"
 fi
 
-declare -a BOOT_OPTIONS
-
 if [[ -f /etc/kernel/cmdline ]]; then
     read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline
-fi
+elif [[ -f /usr/lib/kernel/cmdline ]]; then
+    read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline
+else
+    declare -a BOOT_OPTIONS
 
-if ! [[ ${BOOT_OPTIONS[*]} ]]; then
     read -r -d '' -a line < /proc/cmdline
     for i in "${line[@]}"; do
         [[ "${i#initrd=*}" != "$i" ]] && continue
@@ -59,12 +59,6 @@ if ! [[ ${BOOT_OPTIONS[*]} ]]; then
     done
 fi
 
-if ! [[ ${BOOT_OPTIONS[*]} ]]; then
-    echo "Could not determine the kernel command line parameters." >&2
-    echo "Please specify the kernel command line in /etc/kernel/cmdline!" >&2
-    exit 1
-fi
-
 if [[ -f /etc/kernel/tries ]]; then
     read -r TRIES </etc/kernel/tries
     if ! [[ "$TRIES" =~ ^[0-9]+$ ]] ; then