Skip to content

boot

Meant to be run as pid 1 as a stage1 init. Performs the necessary early system preparation and execs into scandir start.

Interface

boot [ -h ] [ -c ] [ -m ] [ -s skel ] [ -l log_user ] [ -e environment ] [ -d dev ] [ -b banner ]

This program performs some early preparations, forks a stage2 process that brings up the enabled trees and then execs into scandir start.

Exit codes

Command boot never exits. It forks stage2 and execs into scandir start which runs forever until the machine stops or reboots.

Options

  • -h, --help: prints this help.

  • -c, --container: boot inside a container instead of on real hardware. Container mode is selected only by this option. The boot then follows the same path as a hardware boot — it brings up the services of the enabled trees — so a container runs as a full supervised system, not a single command. Leaving the container differs from rebooting a machine: pid 1 exits with a code instead of handing the machine over to the kernel. Use 66 halt to make pid 1 exit with the code held in the /run/66/container/<owner>/halt file (EXITCODE, default 0); 66 poweroff and 66 reboot make it report a SIGINT and a SIGHUP respectively. If the boot itself fails, pid 1 exits with 111. See the container behaviour under 66 scandir -B.

  • -m, --mount: umount the basename of the LIVE directory set into the init.conf skeleton file, if it is already mounted, and mounts a tmpfs on it. By default, the LIVE basename is mounted if it is not already a valid mountpoint. Otherwise without the -m option, it does nothing.

  • -s, --skeleton skel: an absolute path. Directory that holds skeleton files. By default this will be /etc/66. The default can also be changed at compile time by passing the -D skeleton-dir=DIR option to meson setup. This directory must contain the necessary skeleton files to properly boot the machine, without it the system will not boot.

  • -l, --log-user log_user: the catch-all logger will run as log_user. Default is 66log. The default can also be changed at compile-time by passing the -D 66-log-user=user option to meson setup.

  • -e, --environment environment: an absolute path. stage 1 init empties its environment except the PATH variable before forking stage2 and executing into scandir start in order to prevent kernel environment variables from leaking into the process tree. Then, it import environment from files found at the /etc/66/environment directory (See Environment importation). If you want to define additional environment variables then use this option. Behaves the same as scandir start -e.

  • -d, --dev dev: mounts a devtmpfs on dev. By default, no such mount is performed - it is assumed that a devtmpfs is automounted on /dev at boot time by the kernel or an initramfs.

  • -b, --banner banner: prints banner to /dev/console at the start of the stage 1 init process. Defaults to: [Starts stage1 process ...]

Early preparation

When booting a system, command boot performs the following operations:

  • It prints a banner to /dev/console.

  • It imports the environment variables. See Environment importation below.

  • It parses the init.conf skeleton file.

  • It chdirs into /.

  • It sets the umask to initial_umask.

  • It becomes a session leader.

  • It mounts a devtmpfs on dev, if requested.

  • It uses /dev/null as its stdin (instead of /dev/console). Although stdout and stderr still use /dev/console for now.

  • It checks if the LIVE basename is a valid mountpoint, and if so it mounts it. If requested, it unmounts if the LIVE basename is a valid mountpoint and performs a mount.

  • It creates the LIVE directory invocating 66 -v VERBOSITY -l LIVE scandir -b -c create plus -L user_log if requested.

  • It initiates the early services of every tree of the boot group invocating 66 -v VERBOSITY -l LIVE tree init --group boot — or of TREE alone when that key is set.

  • It performs "the fifo trick" where it redirects its stdout to the catch-all logger's fifo without blocking before the catch-all logger is even up (because it's a service that will be spawned a bit later, when scandir start is executed).

  • It forks a child, also called stage2.

    • The child is blocked until the catch-all logger runs.

    • The child starts the services of every tree of the boot group (or of TREE when pinned).

    • The child becomes a session leader.

  • It also makes the catch-all logger's fifo its stderr.

  • It execs into 66 -v VERBOSITY -l LIVE scandir start with LIVE/scandir/0 (default /run/66/scandir/0) as its scandir.

    • scandir start transitions into 66-scandir which spawns the early services of the boot group (or of TREE when pinned), where one of those services is scandir-log, which is the catch-all logger. Once this service is up boot's command child stage2 unblocks.

    • The child then brings up the services of every enabled tree.

In the unusual event that any of the above processes fail, command boot will try to launch a single-user login namely sulogin to provide the means to repair the system.

Skeleton files

Skeleton files are mandatory and must exist on your system to be able to boot the machine properly. By default those files are installed at /etc/66. Use the -D skeleton-dir=DIR option at compile time to change it.

  • init : the command boot binary is not meant to be called directly or be linked to the binary directory because it takes command line options. Therefore the init skeleton file is used to pass any options to command boot. By default command boot is launched without options. This file is installed at /usr/bin/init.

  • init.conf : this file contains a set of key=value pairs available to a user to configure the boot process. A key that is absent keeps its built-in default, so every key is optional; the name of a key must not be changed. By default:

    • VERBOSITY=1 : increases/decreases the verbosity of the stage1 process.

    • LIVE=/run/66 : an absolute path; creates the scandir at LIVE. The value will depend by default on the -D livedir=live option set at compile time.

    • PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin : the initial value for the PATH environment variable that will be passed on to all starting processes unless it's overridden by PATH declaration with the -e option. It is absolutely necessary for execline and all 66 command binaries to be accessible via PATH, else the machine will not boot.

    • TREE= : optional, and empty by default. When set, it pins boot to a single tree of that name: stage1 initiates its earlier services and stage2 starts the rest. When left empty (the default), boot instead brings up every tree of the boot group, whatever their names — and it is a no-op if no tree is in that group. A tree is put in the boot group with 66 tree create -o groups=boot (such a tree cannot be enabled, which keeps it out of the enabled-trees wave). It is the responsibility of the system administrator to build these trees without errors.

    • UMASK=0022 : sets the value of the initial file umask for all starting processes in octal.

    • CATCHLOG=1 : accepted value are 0 or 1 where 0 ask to not redirects its stdout to the catch-all logger's fifo and 1 ask to redirects its stdout to the catch-all logger's fifo. Default 1.

Kernel command line

Any valid key=value pair set at the init.conf skeleton file can be passed on the kernel command line as parameter:

BOOT_IMAGE=../vmlinuz-linux root=/dev/sda3 ro vga=895 initrd=../intel-ucode.img,../initramfs-linux.img TREE=boot VERBOSITY=4

Environment importation

The environment variables used to launch all commands during the boot process are determined in the following order of precedence. For any key=value pair, the last one encountered takes precedence:

  • Variables imported from the init.conf file.
  • Variables imported from the /etc/66/environment directory.
  • Variables imported from the directory specified with the -e option, if provided.
  • Variables imported from the kernel command line.

See also

  • the event system: once every enabled tree is started, boot raises the boot.done event — or boot.failed if a tree could not start. Any service can react to it, for example to bring up a getty only after the system has finished booting.