395. Boot menu and kernel parameters
This page is for anyone who needs to boot KDOS differently: pick another entry at power-on, add a kernel parameter for one boot or for every boot, change the countdown, or work out why the menu looks or behaves wrongly. KDOS’s boot menu is drawn by the Limine boot loader. The page lists the entries it offers on the live medium and on an installed machine, and which file each menu is read from.
Why KDOS boots through Limine, where the kernel is kept and what each parameter means to the initramfs are explained in Boot and init; this page gives the procedures.
Installation
The boot loader is limine, and it is the only one in the tree. Its recipe builds the BIOS stage, the BIOS and UEFI El Torito images and both EFI loaders, BOOTX64.EFI and BOOTIA32.EFI, from one source, and installs them under /usr/share/limine, together with the limine program whose bios-install verb writes the BIOS boot code. Nothing runs at boot on the running system; Limine has no service script.
Three programs write a limine.conf, and nothing else does:
| Writer | File | When |
|---|---|---|
script/phases/70_image/110_iso.sh |
boot/limine/limine.conf on the ISO9660 filesystem of the medium |
Image build |
kinstall, from kdos-installer and its backend src/system/kinstall-core |
limine.conf at the root of the installed machine’s EFI system partition (ESP), /boot/efi/limine.conf on the running system |
Install |
kdos-bootctl, from kdos-tools |
The /KDOS entries, default_entry and the theme keys of that same file; during a UEFI update trial, also a copy at EFI/kdos/trial/limine.conf |
Every change of the A/B boot state (set-slot, try, deploy, select in the initramfs, mark-good once the boot is confirmed), and every kdos theme |
The memory test entry is added only when memtest86plus is installed, and the firmware boot entry labelled KDOS is written by the installer with efibootmgr on a machine installed through UEFI. A reinstall onto the same ESP, or over a disk whose old ESP is gone, replaces that entry rather than adding a second one; another disk’s live KDOS entry is kept.
Configuration
The live medium’s menu
The medium’s menu is a heredoc in the ISO step, written into the ISO tree and never into the root filesystem:
BOOT_THEME=$(kdos-bootctl theme --print "$KDOS_ACCENT")
# The first entry names the release, read from the root's os-release, so the
# menu says which KDOS the medium starts. A root without VERSION_ID is fatal:
# an image that cannot say its version is not one to ship.
LIVE_VERSION=$(. /etc/os-release && printf '%s' "$VERSION_ID")
if [ -z "$LIVE_VERSION" ]; then
echo "FATAL: /etc/os-release has no VERSION_ID" >&2
exit 1
fi
# EVERY LIVE ENTRY NAMES ITS MEDIUM. The initramfs scans every block device for
# an ISO 9660 filesystem holding system.sfs, and a machine with two KDOS media
# attached answers on both; without a name it takes the first to respond, which
# pairs this kernel and its modules with another release's system.sfs and
# makes the installer mark the wrong device as the boot medium. The id is the
# first 16 hex digits of system.sfs's sha256, written beside it as
# kdos-medium.id and passed as kdos.medium=; the scan takes only the medium
# whose file matches. A Ventoy stick in normal mode and a `kdos clone` copy
# carry the same file and this same limine.conf, so they match themselves.
# The id is also the image's Volume Set Identifier (-volset, at 32 KiB + 190
# in the primary volume descriptor), where the installer reads it off every
# whole disk: two copies of one build answer to one id, the scan mounts the
# first, and nothing tells which the firmware started, so the installer
# refuses every disk that carries it. And it is the Publisher Identifier
# (-publisher, at 32 KiB + 318, upper-cased by xorriso as ISO 9660 asks),
# which udev's blkid exports as ID_FS_PUBLISHER_ID where it exports no volume
# set: the graphical installer's probes run as a user who cannot open a disk,
# and read it there.
# Computed after the last write to system.sfs: the /ports append changes it.
MEDIUM_ID=$(sha256sum $ISO_ROOT/system.sfs | cut -c1-16)
case "$MEDIUM_ID" in
[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ;;
*) echo "FATAL: cannot hash $ISO_ROOT/system.sfs for the medium id" >&2
exit 1 ;;
esac
printf '%s\n' "$MEDIUM_ID" > $ISO_ROOT/kdos-medium.id
echo "Medium id: $MEDIUM_ID"
cat > $ISO_ROOT/boot/limine/limine.conf <<EOF
timeout: 10
default_entry: 1
$BOOT_THEME
$WALLPAPER
$FONT_LINES
/KDOS Live
comment: Start KDOS $LIVE_VERSION from this medium
protocol: linux
path: boot():/boot/vmlinuz
module_path: boot():/boot/initrd.img
cmdline: root=/dev/ram0 rw console=tty0 console=ttyS0,115200n8 quiet loglevel=3 kdos.medium=$MEDIUM_ID
/KDOS Live (clean session)
comment: Ignore the persistence store and start fresh
protocol: linux
path: boot():/boot/vmlinuz
module_path: boot():/boot/initrd.img
cmdline: root=/dev/ram0 rw console=tty0 console=ttyS0,115200n8 quiet loglevel=3 nopersist kdos.medium=$MEDIUM_ID
/KDOS Live (verbose)
comment: Every kernel and boot message on the screen, no splash
protocol: linux
path: boot():/boot/vmlinuz
module_path: boot():/boot/initrd.img
cmdline: root=/dev/ram0 rw console=ttyS0,115200n8 console=tty0 loglevel=7 kdos.medium=$MEDIUM_ID
EOF
script/phases/70_image/110_iso.sh, lines 345–412
$BOOT_THEME is the output of kdos-bootctl theme --print for the accent the image is built in; $WALLPAPER and $FONT_LINES name the backdrop and the converted Terminus face, when the build found them. The memory test entry is appended after it:
MEMTEST=/usr/share/kdos/memtest86plus/memtest.efi
if [ -f "$MEMTEST" ]; then
echo "Adding memtest86+..."
cp "$MEMTEST" $ISO_ROOT/boot/memtest.efi
cat >> $ISO_ROOT/boot/limine/limine.conf <<EOF
/Memory Test (memtest86+)
comment: Test this machine's RAM (UEFI only)
protocol: efi
if_fw_type: UEFI
path: boot():/boot/memtest.efi
EOF
else
echo "memtest86+: no payload at $MEMTEST — skipping the menu entry"
fi
script/phases/70_image/110_iso.sh, lines 426–440
The medium is ISO9660 and read-only, so this file cannot be edited on a written stick. A change for one boot is made in Limine’s editor (see Usage); a lasting change is a change to 110_iso.sh and a new image.
The installed machine’s menu
kinstall writes the installed menu at the root of the ESP. In each cmdline: line, the two %s between kdos_slot=a and root= become bootstate=UUID=<esp> and, on an encrypted install, cryptdevice=UUID=<luks>:kdosroot, from src/system/kinstall-core/install.c:
wr("/boot/efi/limine.conf",
"# Written by the KDOS installer.\n"
"timeout: 10\n"
"default_entry: 1\n"
"\n"
"%s"
"%s%s"
"\n"
"/%s\n"
" comment: Start this computer (slot A%s)\n"
" protocol: linux\n"
" path: boot():/EFI/kdos/a/vmlinuz\n"
" module_path: boot():/EFI/kdos/a/initramfs.cpio.gz\n"
" cmdline: kdos_slot=a %s%sroot=UUID=%s rw console=tty0 " KI_QUIET "\n"
"\n"
"/%s (verbose)\n"
" comment: Every kernel message on the console\n"
" protocol: linux\n"
" path: boot():/EFI/kdos/a/vmlinuz\n"
" module_path: boot():/EFI/kdos/a/initramfs.cpio.gz\n"
" cmdline: kdos_slot=a %s%sroot=UUID=%s rw console=tty0 loglevel=7\n"
"\n"
"/%s (single user)\n"
" comment: A root shell for root's password, no desktop\n"
" protocol: linux\n"
" path: boot():/EFI/kdos/a/vmlinuz\n"
" module_path: boot():/EFI/kdos/a/initramfs.cpio.gz\n"
" cmdline: kdos_slot=a %s%sroot=UUID=%s rw console=tty0 loglevel=7 single\n"
"%s%s",
theme, paper, fontline, name, a_note,
slot_opt, crypt_opt, root_uuid, name,
slot_opt, crypt_opt, root_uuid, name,
slot_opt, crypt_opt, root_uuid, b_entry, memtest);
src/system/kinstall-core/install.c, lines 4009–4041
KI_QUIET is quiet loglevel=3 vt.global_cursor_default=0: no kernel message below an error and no text cursor is drawn between the splash and the login screen. The %s at the head of each entry’s title becomes KDOS <version> from the target’s /etc/kdos-release (KDOS 0.2, KDOS 0.2 (verbose), KDOS 0.2 (single user)), or plain KDOS when the target has no record, and the %s in the first entry’s comment becomes , KDOS <version> (Start this computer (slot A, KDOS 0.2)) or nothing; the slot B entry’s title names its release the same way (KDOS 0.2 (slot B)). The next-to-last %s is that /KDOS <version> (slot B) entry, written only on the A/B layout, which boots the second root once with nothing confirmed; the last is the memory test entry.
The file is /boot/efi/limine.conf. The ESP is mounted with umask=0077, as the installer’s fstab line says, so only root can read or change anything under /boot/efi.
The installed menu carries the medium’s colours, backdrop (EFI/kdos/wallpaper.png) and face (EFI/kdos/font.bin, with the term_font lines). The installer copies the face from /mnt/iso/boot/limine/font.bin on the live medium, which stays readable because the target is mounted beside it at /mnt/kinstall, or from the running system’s own ESP when it is run from an installed KDOS. Without either the menu is drawn in Limine’s built-in face; the entries and colours are unaffected.
What kdos-bootctl rewrites
kdos-bootctl regenerates every entry whose title starts with /KDOS, and default_entry, from the boot state, and writes the file only when the text differs. The other slot’s entry is left out while the state marks that slot unfilled, so a slot an update stopped writing cannot be picked by hand until the update finishes it (see A/B slots and rollback). It builds every /KDOS command line from the first /KDOS entry’s, less the words it sets per entry:
/*
* The kernel command line every /KDOS entry is built from: the first /KDOS
* entry's, less the words the generator owns — which slot, which root, which
* menu the entry is in (`kdos_menu=`), and the verbosity each entry sets for
* itself (BC_QUIET, `loglevel=`, `single`).
* Everything else carries over, so `bootstate=`, the command line's
* `cryptdevice=` and anything added by hand survive every regeneration.
*/
static int menu_template(const char *conf, KbBuf *base)
{
const char *cur = conf;
Line l;
int in = 0;
while (line_next(&cur, &l)) {
if (!is_indented(&l)) {
if (in && l.n && l.p[0] == '/')
return -1; /* an entry with no cmdline */
in = in || (l.n && is_ours(&l));
continue;
}
if (!in)
continue;
const char *v = l.p;
const char *end = l.p + l.n;
while (v < end && (*v == ' ' || *v == '\t'))
v++;
if ((size_t)(end - v) < 8 || strncmp(v, "cmdline:", 8))
continue;
v += 8;
while (v < end) {
while (v < end && (*v == ' ' || *v == '\t'))
v++;
const char *w = v;
while (v < end && *v != ' ' && *v != '\t')
v++;
size_t wn = (size_t)(v - w);
if (!wn || (wn == 5 && !strncmp(w, "quiet", 5)) ||
(wn == 6 && !strncmp(w, "single", 6)) ||
(wn >= 9 && !strncmp(w, "loglevel=", 9)) ||
(wn >= 25 &&
!strncmp(w, "vt.global_cursor_default=", 25)) ||
(wn >= 10 && !strncmp(w, "kdos_slot=", 10)) ||
(wn >= 10 && !strncmp(w, "kdos_menu=", 10)))
continue;
/* root= is kept as a marker, so the slot's root lands
* where the command line had it. */
if (base->n)
kb_buf_str(base, " ");
if (wn >= 5 && !strncmp(w, "root=", 5))
kb_buf_str(base, "root=");
else
kb_buf_add(base, w, wn);
}
return 0;
}
src/system/kdos-tools/bootctl.c, lines 957–1012
Every other word carries over, so a word you add to the first entry’s cmdline reaches every /KDOS entry the next time the menu is regenerated, and a word you add only to another entry is dropped. timeout, wallpaper, term_font, the memory test entry and every line that is not part of a /KDOS entry or a theme key are left as they are.
The theme keys are the ones kdos-bootctl theme owns: interface_branding, interface_help_hidden, interface_help_colour, interface_help_colour_bright, backdrop, term_background, term_foreground, term_palette, term_palette_bright, term_margin, term_margin_gradient, wallpaper_style and term_font_scale. A restamp also removes interface_branding_colour, term_background_bright, term_foreground_bright and the _color spellings of the colour keys, which the shipped block does not set. A hand edit of any of them lasts until the next accent change. How the restamp places them is in Restamping an installed machine.
Module options
A driver that is loaded as a module can be given its parameters by an options line in a file under /etc/modprobe.d/, or kept from loading by a blacklist line. The file is read whenever the module loads, and needs no change to the menu. KDOS ships one such file of its own, a blacklist; any other file there comes from the package that owns the driver’s tools, such as nvdimm-security.conf from ndctl, which the ISO carries, and stlink_v1.conf from stlink, once it is installed:
# The kernel claims an RTL2832U as a DVB-T tuner on plug-in, which leaves
# librtlsdr unable to open a device that is present and enumerated.
# /etc/udev/rules.d/70-kdos-sdr.rules is the access half of the same fix.
blacklist dvb_usb_rtl28xxu
fs/etc/modprobe.d/kdos-sdr.conf
The installer and kdos-settingsd, on a time-zone change, write an options file, /etc/modprobe.d/kdos-regdom.conf, described on Microcode and firmware.
Usage
Reaching the menu
- Start the machine. The menu counts down for the number of seconds
timeout:names. - Press Up or Down during the countdown. The countdown stops and the menu waits. Enter, Space and Right boot the highlighted entry at once, even during the countdown.
- Choose an entry with the arrow keys and press Enter.
| Live medium | Installed machine |
|---|---|
KDOS Live |
KDOS <version> |
KDOS Live (clean session): adds nopersist |
KDOS <version> (verbose): loglevel=7, no quiet and no splash |
KDOS Live (verbose): loglevel=7, no quiet and no splash |
KDOS <version> (single user): loglevel=7 single, no splash |
Memory Test (memtest86+), UEFI only |
KDOS <version> (slot <X>), when the other root slot has a root and a kernel and is not marked unfilled |
Memory Test (memtest86+), UEFI only |
The live medium’s quiet entries carry console=tty0 console=ttyS0,115200n8. The kernel prints its messages on both, and the last one named, the serial line at 115200 baud, becomes /dev/console, where the initramfs and rcS print theirs. KDOS Live (verbose) names them the other way round, so there the screen is /dev/console. Every live entry also carries kdos.medium=<id>, the id in the medium’s kdos-medium.id, so the initramfs mounts this medium and not another KDOS medium attached to the machine; an entry edited in Limine’s editor keeps it. An installed machine’s entries carry console=tty0 alone, so everything prints on the screen. An entry without quiet runs no splash, and its console log level stays the one loglevel= set for the whole boot. See the table of parameters for every word KDOS reads.
Adding a parameter for one boot
This works on the live medium and on an installed machine alike, and changes no file.
- Stop the countdown and highlight the entry.
- Press
E. Limine opens its editor on the entry, with the cursor on its first line,comment:. - Move down to the
cmdline:line (the fifth), pressEnd, and add the word, separated by a space. A line longer than the editor wraps, marked with arrows at both edges. - Press
F10(orCtrl+X) to boot the edited entry, orEscto discard the edit.
The editor names these two keys at its top, as ESC Discard and Exit and F10/CTRL+X Boot. The menu itself shows no key list, because the KDOS theme sets interface_help_hidden: yes.
Adding a parameter to every boot of an installed machine
- Open the menu as root, for example
sudo nano /boot/efi/limine.conf. - Add the word to the
cmdline:line of the first/KDOSentry. Leavekdos_slot=,bootstate=,root=andcryptdevice=as they are. - Save the file and run
sync. The ESP is FAT and has no journal. - Reboot. Once the boot is confirmed,
kdos-bootctl mark-goodregenerates every/KDOSentry from the first, and the others carry the word as well. A boot is confirmed whenrcShas finished and the desktop session, or the login screen on a machine SDDM does not log in automatically, has answered for a minute;kdos-sysupdatedruns the command then (see A/B slots and rollback). The regeneration puts the added word in front of the words it sets per entry, so… console=tty0 quiet loglevel=3 vt.global_cursor_default=0 foo=1comes back as… console=tty0 foo=1 quiet loglevel=3 vt.global_cursor_default=0. - Check it:
cat /proc/cmdline.
Do not add quiet, single, a loglevel= or a vt.global_cursor_default= there: kdos-bootctl removes those words from the template and sets them per entry. kdos.splash= is kdos-bootctl splash’s to write (see Theming).
Changing the countdown
Edit timeout: in /boot/efi/limine.conf as root. kdos-bootctl never rewrites it. The value is in seconds. no draws the menu and waits with no countdown. A value of 0 boots the default entry without drawing the menu at all, so the verbose, single-user and memory test entries cannot be reached. Limine’s own description of the key is in /usr/share/doc/limine/CONFIG.md.
Changing the colours
kdos theme <accent> repaints the menu along with the rest of the desktop: kdos-powerd runs kdos-bootctl theme <accent> for it, which rewrites only the theme keys of the menu and the console palette in /etc/vtrgb. Between two accents only the five colour lines differ (interface_help_colour, interface_help_colour_bright, term_foreground, term_palette, term_palette_bright). backdrop and term_background are the backdrop image’s neutral floor under every accent, because Limine cannot retint the image, and paper, whose dark text cannot be read on that floor, writes the same block as bone. Run as root, sudo kdos-bootctl theme <accent> does the same without the session, and prints text consoles are now <accent> at the next login prompt and boot menu is now <accent>. To see the block an accent would write without changing anything:
kdos-bootctl theme --print amber
See Theming for what can be changed and what cannot.
Tips
cat /proc/cmdlineprints the command line the running kernel was given, which is the quickest way to tell which entry booted and whether an edit took.default_entryis regenerated bykdos-bootctlto point at the first/KDOSentry, so a hand edit of it lasts only until the next boot that reachesmark-good.- On the live medium, the clean-session entry is the way past a persistence store that stops the desktop; see Live persistence.
emergencyhas no menu entry. Add it in the editor for one boot; see Emergency mode.- The menu shows a memory test only on UEFI, because the payload is an EFI program and the entry carries
if_fw_type: UEFI. - The initramfs reads no
init=word: it always hands over to/sbin/initon the root.
Troubleshooting
The firmware finds nothing to boot. On UEFI, check that Secure Boot is off in the firmware setup: Limine’s EFI loader is unsigned. Then, from a working system or the live medium, check that EFI/BOOT/BOOTX64.EFI exists on the ESP and that efibootmgr lists a KDOS entry, which the installer puts first in BootOrder, its line ending in KDOS HD(<n>,GPT,…)/\EFI\BOOT\BOOTX64.EFI, where <n> is the ESP’s partition number (1 in the installer’s erase layout) and the loader is BOOTIA32.EFI on 32-bit firmware. On BIOS, the boot code is written by limine bios-install <disk> 2, which puts Limine’s stage into partition 2, the 1 MiB BIOS boot partition of the installer’s layout, and the second stage, limine-bios.sys, is found by name at the root of the ESP, where the installer puts it; restoring both is a step of Recovering an unbootable system. sudo sfdisk -d <disk> lists that partition with type=21686148-6449-6E6F-744E-656564454649; a GPT disk without one starts only on UEFI firmware.
The menu appears in Limine’s own font and colours, with no backdrop. Limine falls back to its own terminal when the theme leaves it fewer rows than it needs. Check term_margin against the ceiling in The margin ceiling; kdos theme <accent> writes the shipped value back. A missing EFI/kdos/font.bin or EFI/kdos/wallpaper.png changes only the face or the backdrop, never the entries.
The menu shows only Limine <version> (x86-64, UEFI) in cyan and [config file contains no valid entries] or [config file not found]. The first is a limine.conf that is empty or has no entries, which is what an ESP left unflushed by a power cut can show after the boot’s fsck -A -a has repaired it; the second is a missing limine.conf. Write the entries back from the live medium; see Putting the boot loader back.
The menu is gone: the machine boots straight into KDOS. timeout: is 0. Set it back as root in /boot/efi/limine.conf.
A parameter added to the file is missing from /proc/cmdline. It was added to an entry other than the first /KDOS entry, or it is one of the words kdos-bootctl sets per entry, and the regeneration at the end of the last boot replaced it. Add it to the first /KDOS entry.
The menu shows a KDOS <version> (slot <X>) entry, or its first entry’s comment speaks of an update or a trial. The other root slot has a root and a kernel, or an A/B trial is in progress: an update when the candidate is newer than the confirmed slot, a trial of this version when it is older or equal. See A/B slots and rollback.
kdos-bootctl theme reports no bootloader configuration and an unchanged boot menu. It printed no bootloader configuration at /boot/efi/limine.conf — boot menu unchanged (and still exits 0, after repainting the consoles): it found no limine.conf there, which is the case on the live medium and on a machine whose ESP is not mounted. Check findmnt /boot/efi.
Known gaps
- Secure Boot is not supported
- 32-bit UEFI is built and has never been booted
- Per-slot kernels have been booted on virtual firmware only, which covers the menu
kdos-bootctlregenerates
See also
- Limine and the kernel command line: where the kernel is kept, the menu, every parameter KDOS reads
- The boot menu: the installed menu, from the installer’s side
- kdos-bootctl: every verb
- Theming
- A/B slots and rollback: the boot state behind the slot entries, trials and rolling back
- The initramfs and the rescue shell: what reads the kernel command line first, and the shell it opens when a boot cannot finish
- Recovering an unbootable system: finding where a boot stopped and repairing it, including a boot loader that is gone
- Modules and sysctl: module options and kernel parameters set from files instead of the command line
- Init and runlevels:
/etc/inittab, single-user and emergency mode