4629713 2026-10-03
devd
early
man
services
tmpfiles
udev
.mailmap 360 B
CMakeLists.txt 2.5 KB
COPYING.md 1.3 KB
init 2.2 KB
README.md 5.3 KB
shutdown-hook 561 B

dinit-ferdios

This is the core services suite for dinit as used by ferdiOS.

Forked from https://github.com/chimera-linux/dinit-chimera/

Building

cmake -B build -DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
cmake --install build

Relevant cache variables: INSTALL_SBINDIR, INSTALL_LIBDIR, INSTALL_LIBEXECDIR, INSTALL_MANDIR, DEFAULT_PATH_ENV, BLESS_BOOT_PATH, DINIT_CONSOLE_PATH, DINIT_DEVD_PATH and DINIT_SULOGIN_PATH.

Kernel command line

This suite implements a variety of kernel command line parameters that you can use for debugging and other purposes.

Dinit arguments

  • dinit_auto_recovery=1 - passes --auto-recovery
  • dinit_quiet=1 - passes --quiet
  • dinit_log_file=LOGFILE - passes --log-file LOGFILE
  • dinit_log_level=LOGLEVEL - passes --log-level LOGLEVEL
  • dinit_console_level=LOGLEVEL - passes --console-level LOGLEVEL

These are notably useful for early boot debugging.

Additionally, there are more parameters that are purely for the purpose of boot debugging and are implemented by dinit-ferdios itself:

  • dinit_early_debug=1 - enables early debugging, causing each early service to echo a message before it performs its action; the following parameters only take effect if this is set
  • dinit_early_debug_slow=N - sleeps N seconds after the echo and before performing the action, intentionally slowing down the boot process for better clarity
  • dinit_early_debug_log=LOGFILE - instead of the console, all output will be redirected to the LOGFILE; note that you have to ensure the location of the file is writable

The debug parameters are subject to change if necessary. They become a part of the global activation environment.

Fsck arguments

  • fastboot or fsck.mode=skip - skips filesystem checks
  • forcefsck or fsck.mode=force - passes -f to fsck
  • fsckfix or fsck.repair=yes - passes -y to fsck (do not ask questions)
  • fsck.repair=no - passes -n to fsck

Kdump arguments

These only apply if the optional kdump service is installed.

  • nokdump - do not save kernel dump even if /proc/vmcore exists

Tmpfs arguments

  • dinit.runsize=N or initramfs.runsize=N - the size= parameter to use when mounting /run and /run/user; they are equivalent and the former is specific to dinit, while the latter exists for compatibility with initramfs-tools (as the initramfs will mount /run already and then dinit-ferdios will not). Defaults to 10%.

Mount arguments

  • dinit_early_root_remount=VAL the extra remount parameters to use for early root remount; the default is ro,rshared - this can be used to prevent read-only remount of the root filesystem, e.g. for debugging. Note that this variable makes it into the global activation environment.

Device dependencies

The dinit-ferdios suite allows services to depend on devices. To facilitate this, it needs a suitable device monitor.

Dummy monitor/client are provided by default. You can replace them when installing a proper one.

The capabilities depend on the device monitor implementation.

Example service that will not come up unless /dev/sda1 is around, and will shut down if /dev/sda1 disappears:

type = process
command = /usr/bin/foo
depends-on: local.target
depends-on: device@/dev/sda1

See the documentation for your device monitor for further capabilities.

Zram support

This suite supports management of zram devices on Linux.

The following configuration files are checked:

/etc/dinit-zram.d/*.conf
/run/dinit-zram.d/*.conf
/usr/local/lib/dinit-zram.d/*.conf
/usr/lib/dinit-zram.d/*.conf
/etc/dinit-zram.conf

The directory snippet paths are checked in that order and the first directory to contain a config snippet of that name is prioritized (i.e. every file name is only loaded once). The /etc/dinit-zram.conf configuration file is loaded last and always (if it exists).

The syntax is like this:

; a comment
# also a comment
[zram0]
size = 4G
algorithm = zstd
format = mkswap -U clear %0

Fields that are specified later override those that are specified earlier, so you can have e.g. a config file defining a zram device and then a later one defining more details for it.

The above fields are currently the only supported ones (more will be added later as well as more syntax). All but size are optional. The format field specifies a command to use to format the device once set up and the default is the one above, to set up swap space. You can set custom commands for e.g. zram ramdisks with real filesystems on them.

Once you have a configuration file, you can activate the device by enabling the zram-device@zramN service.

Mount services

This suite supports mount services, which are service-driven supervised mounts. You can define a mount service like this:

# /etc/dinit.d/usb-stick.mount
type = process
command = $DINIT_MOUNT \
    --from PARTLABEL=usbstick \
    --to /media/usb \
    --type ext4
restart = false
depends-on: device@PARTLABEL=usbstick
depends-on: early-fs-local.target

Starting this service will ensure that /dev/sda1 will remain mounted for as long as the device exists. Stopping the service will cleanly unmount it. The restart = false ensures manually unmounting the device will not remount it; restart = true will make sure it's always mounted, unless stopped explicitly.