Skip to content

Commit

Permalink
kernel-install: Only read cmdline from /proc/cmdline when not in cont…
Browse files Browse the repository at this point in the history
…ainer

If we're running from within a container, we're very likely not going
to want to use the kernel command line from /proc/cmdline, so let's add
a check to see if we're running from a container to decide whether we'll
use the kernel command line from /proc/cmdline.

(cherry picked from commit 35c01ec59e0c2e6bd06cb18ca2ff612c6a7ea35d)
(cherry picked from commit c386327fc851863abf4c27076bd368dfc55b83a0)
  • Loading branch information
DaanDeMeyer authored and bluca committed Aug 16, 2024
1 parent ce63101 commit 0b4d00b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/kernel-install/90-loaderentry.install.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ elif [ -f /etc/kernel/cmdline ]; then
BOOT_OPTIONS="$(tr -s "$IFS" ' ' </etc/kernel/cmdline)"
elif [ -f /usr/lib/kernel/cmdline ]; then
BOOT_OPTIONS="$(tr -s "$IFS" ' ' </usr/lib/kernel/cmdline)"
else
elif ! systemd-detect-virt --container --quiet; then
BOOT_OPTIONS="$(tr -s "$IFS" '\n' </proc/cmdline | grep -ve '^BOOT_IMAGE=' -e '^initrd=' | tr '\n' ' ')"
else
BOOT_OPTIONS=""
fi

BOOT_OPTIONS="${BOOT_OPTIONS% }"
Expand Down Expand Up @@ -194,7 +196,7 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
echo "machine-id $MACHINE_ID"
fi
[ -n "$SORT_KEY" ] && echo "sort-key $SORT_KEY"
echo "options $BOOT_OPTIONS"
[ -n "$BOOT_OPTIONS" ] && echo "options $BOOT_OPTIONS"
echo "linux $KERNEL_ENTRY"
[ -n "$DEVICETREE_ENTRY" ] && echo "devicetree $DEVICETREE_ENTRY"

Expand Down

0 comments on commit 0b4d00b

Please sign in to comment.