generate-kernel-cmdline(Configuration)

πŸ“¦ version 1.0, in alpine 3.24

okay so bestie, welcome to generate-kernel-cmdline from the Configuration manual β€” and it’s literally giving a UAPI.6 compliant configuration system for generating kernel command lines in postmarketOS. πŸ’… It supports adding and removing specific kernel parameters, gives you a clear three-tier configuration hierarchy with well-defined ordering (distro defaults β†’ device maintainer config β†’ user overrides), and lets packages do their own config thing without touching shared defaults (similar to how initramfs files are handled). It uses layered config directories with vendor/user separation: /usr/lib for distro and packages, and /etc for users/system admins. Config files list kernel command line parameters that can be added or removed, so distros, packages, and users can override each other. No cap. ✨


πŸ—‚ Config Directory Structure ✨

/usr/lib/kernel-cmdline.d/  # Distro and package config files
/etc/kernel-cmdline.d/      # System admin config files

πŸ”„ Processing Order 🫢

  1. /usr/lib/kernel-cmdline.d/*.conf
  2. /etc/kernel-cmdline.d/*.conf

Config files are parsed lexicographically within each directory per UAPI.6 spec. ⭐


πŸ“ File Format πŸ’–

Extension: .conf

Syntax (one directive per line):

  • param β€” add parameter
  • param=value β€” add parameter with value
  • -param β€” remove param
  • -param=value β€” remove param=value
  • # comment β€” comment
  • Empty lines ignored

🧠 Processing Rules πŸ‘‘

Each directive is independent. Multiple instances of the same parameter name coexist unless matched for removal. Periodt.

Example 🌸

Starting cmdline: console=tty0 console=ttyMSM0,115200 quiet

To remove console=ttyMSM0,115200, add this to a config file with a higher priority:

-console=ttyMSM0,115200

Result: console=tty0 quiet


πŸ«₯ Masking πŸ’€

Empty file or symlink to /dev/null masks file at same path in lower-priority directory, per UAPI.6 spec. That’s the whole mood. πŸŽ€


🌈 Examples πŸ¦‹

Base Distro Config πŸ’œ

/usr/lib/kernel-cmdline.d/00-defaults.conf:

console=tty0
quiet
loglevel=4

Device Package πŸ“±

/usr/lib/kernel-cmdline.d/50-pinephone.conf:

console=ttyMSM0,115200
-quiet

Result: console=tty0 console=ttyMSM0,115200 loglevel=4

User Override πŸ™ˆ

/etc/kernel-cmdline.d/debug.conf:

-quiet
debug
loglevel=7

Result: console=tty0 console=ttyMSM0,115200 loglevel=7 debug

Replacing a Parameter πŸ”₯

/etc/kernel-cmdline.d/local.conf:

-console=ttyMSM0,115200
console=ttyUSB0,9600

Result: console=tty0 console=ttyUSB0,9600 loglevel=7 debug

Masking Example 🧚

To mask the pinephone configuration, create an empty file or symlink:

doas touch /etc/kernel-cmdline.d/50-pinephone.conf

or

doas ln -s /dev/null /etc/kernel-cmdline.d/50-pinephone.conf

This prevents /usr/lib/kernel-cmdline.d/50-pinephone.conf from being parsed. 🫢


πŸ’– That’s the whole page, bestie β€” footer says generate-kernel-cmdline(Configuration), and since the original doesn’t give a source/version or date, I’m not making one up. Slay. ✨

πŸ“¦ where this page comes from