diff --git a/man/kernel-install.xml b/man/kernel-install.xml
index 38c183be243..0bf57b4d534 100644
--- a/man/kernel-install.xml
+++ b/man/kernel-install.xml
@@ -616,9 +616,9 @@
/proc/cmdline
Specifies the kernel command line to use. The first of the files that is found will be used.
- When running in a container, /proc/cmdline is ignored.
- $KERNEL_INSTALL_CONF_ROOT may be used to override the search path; see below for
- details.
+ Lines starting with the # character are ignored. When running in a container,
+ /proc/cmdline is ignored. $KERNEL_INSTALL_CONF_ROOT may be
+ used to override the search path; see below for details.
diff --git a/src/kernel-install/60-ukify.install.in b/src/kernel-install/60-ukify.install.in
index 076390dd047..310b6f26caf 100755
--- a/src/kernel-install/60-ukify.install.in
+++ b/src/kernel-install/60-ukify.install.in
@@ -185,7 +185,12 @@ def devicetree_file_location(opts) -> Optional[Path]:
def kernel_cmdline_base() -> list[str]:
path = input_file_location('cmdline')
if path:
- return path.read_text().split()
+ # Filter out commented out lines from cmdline.
+ lines = path.read_text().splitlines()
+ return [opt
+ for line in lines
+ if not line.startswith('#')
+ for opt in line.split()]
# If we read /proc/cmdline, we need to do some additional filtering.
options = Path('/proc/cmdline').read_text().split()
diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh
index e2add8ba80b..399979a0260 100755
--- a/src/kernel-install/test-kernel-install.sh
+++ b/src/kernel-install/test-kernel-install.sh
@@ -29,7 +29,12 @@ mkdir -p "$D/sources"
echo 'buzy image' >"$D/sources/linux"
echo 'the initrd' >"$D/sources/initrd"
echo 'the-token' >"$D/sources/entry-token"
-echo 'opt1 opt2' >"$D/sources/cmdline"
+
+cat >"$D/sources/cmdline" <"$D/sources/install.conf" <