Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

447. Recovering an unbootable system

This page is the procedure for an installed KDOS machine that does not reach a working desktop: how to tell where the boot stopped, which way in each case leaves you (the recovery console, the rescue shell, single-user and emergency mode, the live medium), and how to repair the common causes from there: a failing service, a damaged filesystem, a kernel missing from the EFI system partition (ESP), a boot loader that is gone, an update that will not boot. The boot path itself is explained in Boot and init; this page gives the procedures.

Installation

Every way in ships on the image; nothing has to be installed beforehand. One thing has to be set up in advance: a root password, for single-user and emergency mode.

Way in Provided by Reached
The recovery console, a plain login on tty2 fs/etc/inittab, agetty from util-linux Ctrl+Alt+F2 from the desktop, Alt+F2 from a text console
The rescue shell The initramfs init (script/phases/70_image/090_initramfs.sh) By itself, when the initramfs cannot find, unlock or mount the root
Single-user mode sysvinit and sulogin from util-linux The KDOS <version> (single user) menu entry
Emergency mode The same emergency added to an entry in Limine’s editor
The live medium The KDOS stick the machine was installed from, or any later one The firmware’s boot menu
A memory test memtest86plus The Memory Test (memtest86+) menu entry, UEFI only

The live medium carries every tool the procedures below use: cryptsetup, lvm and vgchange, mdadm, e2fsck, fsck.fat, limine, efibootmgr and kdos-bootctl.

Configuration

The consoles and single-user mode are entries of /etc/inittab, shipped from fs/etc/inittab:

# Runlevel 3 is the running system. S is single-user: sulogin on the
# console, no consoles from this file. 0 powers off and 6 reboots.
id:3:initdefault:

si::sysinit:/etc/init.d/rcS

# sulogin asks for root's password on the console. Leaving its shell
# continues to runlevel 3. The initramfs passes `single` from the kernel
# command line, and `telinit S` reaches it from a running system. -p makes
# the shell a login shell, which reads /etc/profile: init's own PATH does not
# reach /usr/local, where `kdos` and the other KDOS commands live.
~~:S:wait:/sbin/sulogin -p

# Local Console (QEMU Window / Physical) — the display manager.
#
# kdos-dm execs SDDM, whose greeter compositor takes tty1. It is started here
# and never from rcS: init reaches this line only once rcS has returned, and the
# splash stops drawing synchronously at its end (`kdos-splash handoff`), its
# settled frame left on screen for the compositor's first frame to replace, so
# the compositor's modeset never races the splash for the DRM master.
#
# A MISSING OR FAILING SDDM STILL GIVES A CONSOLE. sddm stays up across every
# login and logout, so a respawn here is sddm having exited; kdos-dm turns a
# missing binary, a missing account or three exits in a minute into a password
# prompt on tty1 through kdos-getty, never an autologin. Autologin is SDDM's
# alone, in /etc/sddm.conf.d/kde_settings.conf.
1:2345:respawn:/usr/local/sbin/kdos-dm

# Second console, a login prompt for any account. THE RECOVERY CONSOLE: it
# is a plain agetty with no --autologin, and nothing above may be allowed to
# make it one too, because it is what is left when the desktop on tty1 does
# not come up — a greeter SDDM keeps restarting included, which no respawn
# here ever sees. kdos-getty loads the console font and palette after fbcon's
# deferred take-over; doing that in rcS is futile, because the take-over resets
# every VT's font. agetty hands the name to /bin/login, util-linux's PAM login
# (/etc/pam.d/login, through system-login), so a console login is a session
# elogind knows and starts the user's services like any other.
#
# EVERY AGETTY HERE NAMES /etc/issue. agetty built against musl, which has no
# scandirat(), reads no issue file of its own accord, and without
# --issue-file the banner /etc/issue holds is never printed.
2:2345:respawn:/usr/local/sbin/kdos-getty tty2 /sbin/agetty --noclear --issue-file /etc/issue tty2 38400 linux

fs/etc/inittab, lines 11–52

sulogin asks for root’s password. The installer locks root unless it was asked to set a root password (root_locked in an answer file, see The keys), and a locked root leaves single-user and emergency mode with no shell: sulogin prints Cannot open access to console, the root account is locked. and Press Enter to continue., and after Enter the boot carries on to runlevel 3. Set one while the machine works:

sudo passwd root

The service scripts are run by this loop in rcS, which writes each script’s output to a log and skips any script with a marker under /etc/service.disabled/:

INIT_DIR="/etc/init.d"
DISABLED_DIR="/etc/service.disabled"

for _script in "${INIT_DIR}"/[0-9][0-9]_*.sh; do
    [ -x "$_script" ] || continue
    _name=$(basename "$_script" | sed 's/^[0-9][0-9]_//;s/\.sh$//')
    if [ -f "${DISABLED_DIR}/${_name}" ]; then
        echo "[KDOS] Skipping disabled service: ${_name}"
        continue
    fi
    echo "[KDOS] Running: $(basename $_script) start"
    splash step "$(echo "$_name" | tr '[:lower:]' '[:upper:]')"

    # Redirect to a file and print it AFTERWARDS, never through a pipe. A
    # `supervise` points the supervisor and the daemon at its own log
    # forwarder, so a supervised service lets go of the script's output; any
    # other process a script leaves running with that output open would hold
    # a pipe's write end, a `| tee` would never see EOF, and the boot would
    # stop at that service. A file has no reader to wait on.
    #
    # Every message still reaches the console and the serial line, which is
    # the only way to debug a machine that dies behind a splash — just after
    # the step rather than streamed during it.
    _log="/run/kdos-init.${_name}.log"
    "$_script" start >"$_log" 2>&1
    _rc=$?
    cat "$_log"
    _verdict=$(stage_verdict "$_rc" "$_log")
    if [ "$_verdict" != fail ]; then
        splash "$_verdict"
    else
        splash fail
        # The reason, not just the verdict. On the live medium this output
        # goes to the serial line, and the screen shows only the splash.
        while IFS= read -r _l; do
            splash detail "$_l"
        done < <(tail -n 6 "$_log" 2>/dev/null)
        unset _l
    fi
    unset _rc _verdict
done

fs/etc/init.d/rcS, lines 192–232

Usage

Finding where it stopped

The splash names each stage as it runs, so the last name on it says where the boot stopped.

Stopped at Go to
Nothing on screen, or the firmware reports no boot device Putting the boot loader back
The menu appears; the chosen entry stops at once Putting a kernel back on the ESP
An initramfs stage, then a shell on tty1 The rescue shell
ROOT FILESYSTEM HAS ERRORS - RUN e2fsck Repairing from the live medium, step 5
A service stage marked failed, or a stage that never ends A service that fails or hangs
The splash finishes; then a black screen The desktop does not start
The first boot after an update After an update

The full table of stages and their logs is in When a boot stops.

The desktop does not start

  1. Press Ctrl+Alt+F2 (Alt+F2 if the screen is a text console) and log in on tty2.
  2. Run kdos doctor, and read its Session and Desktop sections.
  3. Read the service logs of this boot: ls /run/kdos-init.*.log, and /run/kdos-svc.<name>.log for a supervised daemon, elogind’s among them.
  4. Read the display manager’s log, /var/log/sddm.log, and sudo grep kdos-dm /var/log/messages: SDDM that cannot run leaves a text password prompt on tty1 instead of a black screen.
  5. The procedures for each stage from the greeter to the desktop are on Desktop troubleshooting.

A service that fails or hangs

A failed script does not stop the boot; its stage is marked failed, the last lines of its output are on the splash, and the whole output is in /run/kdos-init.<name>.log. A script that never returns stops the boot at its stage, and no login prompt appears, because the consoles start only after rcS finishes.

  1. If a login prompt appears, log in on tty2 and read /run/kdos-init.<name>.log.

  2. If the boot hangs, reboot into emergency mode (below), which opens a root shell before rcS runs.

  3. Disable the script by its name, without the number and the .sh; for 45_avahi.sh that is avahi:

    touch /etc/service.disabled/<name>
  4. Leave the shell, from emergency mode, or reboot. rcS skips the script, prints [KDOS] Skipping disabled service: <name> on the console, and writes no /run/kdos-init.<name>.log for it. On the live medium the console is the serial line; on an installed machine it is the screen, and the line does not reach /var/log/messages.

  5. Repair the service from the running system, then remove the marker to enable it again.

Single-user mode

  1. Stop the boot menu’s countdown and choose KDOS <version> (single user).
  2. rcS runs as on every boot, so every enabled service starts and every mount in /etc/fstab, the ESP included, is made.
  3. sulogin asks for root’s password on the console: Enter root password for system maintenance and (or press Control-D to continue):. A root login shell opens, with /usr/local/bin and so kdos on its PATH, no getty on any console and no desktop; runlevel prints N S.
  4. Leaving the shell continues to the running system: init prints INIT: Entering runlevel: 3 and the consoles start.

From a running system, sudo telinit S reaches the same state after ending the consoles and the session.

Emergency mode

  1. Stop the countdown, highlight KDOS, and press E.
  2. Add emergency to the cmdline: line, and press F10 to boot it. The editor is described in Adding a parameter for one boot.
  3. sulogin runs before rcS, with the same prompt as single-user mode: only the initramfs’s mounts exist, which are the root, /proc, /sys, /dev with /dev/pts and /dev/shm, and no service has run (/run/kdos-init.*.log does not exist yet; runlevel prints unknown). The initramfs has stopped the splash, so the prompt is on the screen as well as on the serial line. The shell keeps init’s PATH, which does not reach /usr/local/bin: run kdos as /usr/local/bin/kdos, or exec bash -l first.
  4. Leaving the shell continues the boot with rcS, and from there as on any boot.

The rescue shell

The initramfs opens it when it cannot find the root, cannot unlock its container, or finds no /sbin/init on it; the reason is printed above the prompt. What each reason means, the tools the shell has and how to restart from it are on The initramfs and the rescue shell. The two facts to keep in mind: leaving the shell with exit panics the kernel, and sync; echo b > /proc/sysrq-trigger restarts the machine.

Repairing from the live medium

This is the way in that needs no password on the machine and works whatever state the installed system is in. Steps 3 and 4 apply only to a root that is encrypted or on LVM; skip the ones that do not match your disk.

  1. Boot the KDOS stick and open a terminal. On the live medium root’s password is kdos, and the kdos account can use sudo with its own password, which is also kdos.

  2. Find the disk and its partitions: lsblk -f, or sudo blkid.

  3. Open an encrypted root under the name the initramfs uses:

    sudo cryptsetup open /dev/sdX2 kdosroot
  4. Activate any volume groups: sudo vgchange -aay. On a machine installed with two slots on LVM it reports 2 logical volume(s) in volume group "kdos" now active.

  5. Check the filesystems while they are not mounted: sudo e2fsck -f <root device> for an ext root, sudo fsck.fat -a <esp device> for the ESP. btrfs, xfs and f2fs check themselves at mount time.

  6. Mount the root and its ESP:

    sudo mkdir -p /mnt/target
    sudo mount <root device> /mnt/target
    sudo mount <esp device> /mnt/target/boot/efi
  7. Repair what the logs point at: read /mnt/target/var/log/messages, disable a service with sudo touch /mnt/target/etc/service.disabled/<name>, or follow the two procedures below.

  8. Flush and unmount: sync, then sudo umount /mnt/target/boot/efi /mnt/target, and sudo cryptsetup close kdosroot if you opened one. Reboot without the stick.

Putting a kernel back on the ESP

Each slot boots the kernel in EFI/kdos/<slot>/ on the ESP, copied from that root’s /boot. With the root and its ESP mounted as above, kdos-bootctl can be pointed at them through KDOS_BOOTSTATE, from which it also takes the ESP and limine.conf:

sudo KDOS_BOOTSTATE=/mnt/target/boot/efi/EFI/kdos/bootstate kdos-bootctl deploy /mnt/target a

It prints slot a boots 7.2.11 from EFI/kdos/a and regenerates the /KDOS entries of the ESP’s limine.conf. With KDOS_BOOTSTATE redirected and KDOS_EFIVARS unset, it writes no firmware variable. It refuses, and writes nothing, when the ESP has no room for both files or the initramfs carries no modules for the kernel.

When the boot state itself is gone, the same variable recreates it: kdos-bootctl status reports no boot state at … and exits 1 (the ESP is not mounted at … when the target’s ESP is not mounted, which is mounted first), and set-slot a <filesystem-uuid> writes a fresh state with slot A active (set-slot b <uuid> then records a second slot). Run each with the same KDOS_BOOTSTATE= prefix as the deploy above. sudo blkid <root device> prints the filesystem UUID. For an encrypted root, give the LUKS container’s UUID as a third word (sudo blkid /dev/sdX2); kdos-bootctl crypt <fs-uuid> prints it once the container is open.

Putting the boot loader back

With the ESP mounted at /mnt/target/boot/efi, and the whole disk as /dev/sdX:

  1. The UEFI loaders, at the path the firmware falls back to:

    sudo mkdir -p /mnt/target/boot/efi/EFI/BOOT
    sudo cp /usr/share/limine/BOOTX64.EFI /usr/share/limine/BOOTIA32.EFI /mnt/target/boot/efi/EFI/BOOT/
  2. The BIOS second stage, at the root of the ESP, and the BIOS boot code:

    sudo cp /usr/share/limine/limine-bios.sys /mnt/target/boot/efi/
    sudo limine bios-install /dev/sdX 2

    The 2 is the BIOS boot partition, partition 2 of the layout the installer’s erase plan writes, where Limine’s stage goes on a GPT disk. Without the number Limine finds a BIOS boot partition by its type itself (Autodetected partition 2 as BIOS boot partition.), and on a dos (MBR) disk it needs none. A GPT disk with no BIOS boot partition gets error: Installing to a GPT device, but no BIOS boot partition specified or detected., the command undoes its work, and the disk starts only through UEFI.

  3. On a UEFI machine, the firmware entry the installer writes, naming the ESP’s partition number:

    sudo efibootmgr --create --disk /dev/sdX --part <n> --loader '\EFI\BOOT\BOOTX64.EFI' --label KDOS

    The firmware’s removable-media fallback starts EFI/BOOT/BOOTX64.EFI without an entry.

  4. limine.conf itself must still be at the root of the ESP. If it is gone, no tool writes it from nothing; its shape is on Boot menu and kernel parameters. Writing the three /KDOS entries by hand, with the right kdos_slot=, bootstate=UUID= and root=UUID= words, is enough: the next kdos-bootctl write (a set-slot, a deploy, the mark-good that confirms a boot) regenerates the other entries, and, once the machine runs again, kdos theme <accent> (or sudo kdos-bootctl theme <accent>) puts the theme keys back.

These are the installer’s own steps (src/system/kinstall-core/install.c), run by hand. Steps 1, 3 and 4 make the disk start through UEFI; step 2 makes it start on a BIOS machine.

After an update

An A/B update that does not finish booting rolls itself back. To leave it sooner, pick the confirmed slot’s KDOS <version> (slot <x>) entry; see A/B slots and rollback. An update applied with --in-place has no second slot to fall back to: boot the live medium and repair the root as above.

Tips

Troubleshooting

sulogin says the root account is locked. Root has no password. Boot the live medium, mount the root as in Repairing from the live medium, give it the live system’s devices, and set one inside it:

sudo mount --bind /dev /mnt/target/dev
sudo chroot /mnt/target passwd root
sudo umount /mnt/target/dev

passwd asks New password: and Re-enter new password: on the terminal and prints passwd: password changed.; sudo chroot /mnt/target passwd -S root reads root L … before and root P … after. Single-user and emergency mode then ask for that password and open a root shell.

The KDOS <version> (single user) entry boots straight to the normal system. sulogin gave up for the reason above, and after Enter init printed INIT: Entering runlevel: 3 and carried on.

The machine powers on, and the firmware says there is no bootable device. On UEFI, check that Secure Boot is off; Limine’s loader is unsigned. Otherwise put the boot loader back.

The menu appears and every entry fails at once. The kernel or initramfs the entry names is missing from EFI/kdos/<slot>/. Mount the ESP from the live medium and look; then put a kernel back.

fsck: errors left uncorrected on the splash. A filesystem other than the root has errors; the report is in /run/kdos-fsck.log. On the ESP, repair it with fsck.fat from the live medium.

The power button turns the machine off at a text console. That is the setting outside a desktop session: elogind’s HandlePowerKey=poweroff in /etc/elogind/logind.conf.d/50-kdos.conf applies at the login screen and on a console login, and inside a Plasma session the power button opens the logout screen instead. In emergency mode elogind has not started, and the button does nothing. To shut down from a prompt on purpose, use sudo poweroff.

Known gaps

See also