3. The fs/ overlay
Most of a KDOS root is installed by packages, but some 260 files and links belong to no package: the boot scripts, the account databases, the shell profile, the skeleton of a new user’s home, the firewall rules, the desktop’s default settings. They are kept in the repository under fs/, laid out as they sit in the root, and copied into build/fs by the first step of 10_bootstrap, 000_file_system.sh. This chapter says what is in fs/, what that step does with it, and what does not belong there; read it before you add or change a file under fs/.
What fs/ holds
fs/ mirrors the root filesystem. A file at fs/etc/inittab becomes /etc/inittab in the root, and one at fs/usr/local/sbin/kdos-dm becomes /usr/local/sbin/kdos-dm. The main areas are:
fs/etc/-
The system’s own configuration:
inittab, which sysvinit reads, and the boot scripts underinit.d/, numbered scripts thatrcSruns in order at boot, one per service or boot task, withservice.disabled/naming those that must not start;passwd,groupandshadowwith the accounts every machine has;profile,bash.bashrcandprofile.d/;fstab,hostname,hosts,nsswitch.confandresolv.conf; the firewall innftables.confandnftables.d/; KDOS’s own settings underkdos/, such asxkb.confandzram.conf, the per-user services underkdos/user-services/, and the directories of trusted signing keys underkdos/keys/; and configuration for udev, polkit, PipeWire, ALSA, SDDM (sddm.conf.d/), turnstile and the XDG menus and autostart entries. fs/etc/skel/-
The skeleton of a user’s home directory, copied into each home when the image phase creates the users.
fs/root/holds root’s own.bashrcand.bash_profile. fs/usr/local/-
KDOS’s own scripts that belong to no port:
sbin/kdos-dm, which starts the display manager, SDDM, on tty1, and falls back to a password prompt there when SDDM cannot run;bin/kdos-session-wrapper, the command SDDM starts the Plasma session through;- three helpers beside it:
kdos-openarchive, which unpacks an archive no desktop application opens,kdos-updatedb, which rebuilds a user’s own file-name index, andxdg-terminal-exec, which opens a command in Konsole; - under
lib/kdos/:session-common.sh, the shell functions the wrapper and Plasma’s environment script share;timers.sh, the one parser of every timer table, the system’s under/etc/kdos/timers.d/and each user’s; anduser-timers, which runs a user’s own timers.
fs/usr/share/-
Data files:
- under
kdos/: the boot menu’s pictures (boot/), the logo, and the desktop’s default settings, the files underxdg/with extra layers for the live medium (xdg-live/) and for a virtual machine (xdg-vm/), anddata-live/, desktop entries that take the place of the image’s own in the live session alone; - the GSettings override in
glib-2.0/schemas/; - bash completion for
kdos,kdos-appbox,kdos-bootctl,kdos-box,kinstall,kpkgandksvc, and a startup file,startup/ksvc.bash, that givesservicethe same completion asksvc; - the desktop entries of KDOS’s own tools under
applications/, and the menu folder for boxed applications underdesktop-directories/; - the firmware-update remote under
fwupd/remotes.d/.
- under
fs/usr/lib64-
A symbolic link to
lib, so that the root has one library directory. Anything that installs into/usr/lib64lands in/usr/lib. fs/etc/mtab-
A symbolic link to
../proc/self/mounts, the kernel’s list of mounts, for the programs that read or write/etc/mtab: lvm2’slvextend -randmount.nfs4fail without it; see Mount points that must be right.
To see the whole of it, list it from the top of the repository on your machine:
find fs -type f -o -type l | sort
What the copy does with it
000_file_system.sh copies fs/ into the root on every run of 10_bootstrap, with no “already done” marker, so an edit to fs/ reaches the tree the next time the step runs. Because it runs over a tree that packages have already filled, the copy is more than a cp -r, and four things follow for whoever edits fs/:
- An account in
fs/etc/passwd,grouporshadowalways wins over the tree’s entry of the same name, and an account only the tree has, one a package’s install hook added, survives the copy. - A file deleted from
fs/is deleted from the tree on the next run, because the step keeps a manifest of whatfs/provided in/var/lib/kdos/fs-manifest. Only files and links the manifest names are removed, never a directory. - Every regular file from
fs/ends up 755 when it is executable in the repository and 644 when it is not. git carries no other mode and no owner, so a path that needs one, such as/etc/shadowat 600 or the polkit and udev rules owned by root, is listed in a table inside the step. - The link
fs/usr/lib64cannot replace a real directory, so a tree whose/usr/lib64is still a directory keeps it until it is next built from empty.
Each of these is shown line by line, with what goes wrong without it, in The file system, the chapter on that step.
Running the step on its own
After changing anything under fs/, copy it into an existing tree and rebuild the image, without re-running the rest of the bootstrap, with a build plan. From the top of the repository on your machine:
make build BUILD_ARGS="--phases 10_bootstrap,70_image --steps 10_bootstrap:000_file_system.sh"
--phases runs only 10_bootstrap and 70_image, and --steps limits 10_bootstrap to this one script; the image phase runs whole. Narrowing a build explains both.
What does not belong in fs/
fs/ holds what no package installs. A few rules follow from how the copy works and from the system’s own principles:
- No file a package installs. The copy writes over whatever is at a path, so a file both in
fs/and in a package ends up asfs/’s copy the next time the step runs, while the package database still records the package’s. Deleting such a file fromfs/later deletes it from the tree too, package or not, because the manifest named it. Configuration a port installs belongs in its port. - No
fs/etc/X11/. KDOS has no X server on its login path, and the directory must never exist; see No Xorg server. - Nothing for systemd. No unit files and no
systemd-*configuration; services are started by the scripts infs/etc/init.d/. See No systemd. - No mode or owner git cannot carry, unless it is added to the step’s table as well.
See also
- Syncing fs/: the same step in the KDOS book, with the home directories the image phase makes from
/etc/skel - The file system:
000_file_system.shline by line, the copy offs/included - The build tree: where
build/fssits among the build’s other directories - Boot and init: what the scripts in
fs/etc/init.d/do at boot