s6-linux-init
Software
skarnet.org

The s6-linux-init-maker program

s6-linux-init-maker reads configuration options on the command line, and outputs a directory to place in the root filesystem. That directory contains a script suitable as an init program, as well as support file hierarchies to get a complete s6 infrastructure running when the system is booted on that script.

s6-linux-init-maker only writes scripts. At boot time, these scripts will call commands provided by other skarnet.org packages such as execline or s6. It is the responsibility of the administrator to make sure that all the dependencies are properly installed at boot time, and that the correct options have been given to s6-linux-init-maker so that the programs are found on the root filesystem of the machine - else the scripts will crash.

Interface and usage

     s6-linux-init-maker \
       [ -c basedir ] \
       [ -u log_uid -g log_gid | -U ] \
       [ -G early_getty ] \
       [ -1 ] \
       [ -L ] \
       [ -p initial_path ] \
       [ -m initial_umask ] \
       [ -t timestamp_style ] \
       [ -d dev_style ] \
       [ -s env_store ] \
       [ -e initial_envvar ] ... \
       [ -E stage2_envvar ] ... \
       [ -q ] finalsleeptime
       dir

dir should then be copied by the administrator to the place declared as basedir. Be careful: it contains fifos, files with precise uid/gid permissions, and files with non-standard access rights, so be sure to copy it verbatim. The s6-hiercopy tool can do it, as well as the GNU or busybox cp -a or mv commands.

The basedir/bin directory contains scripts, or links to programs, that are suitable as System V-compatible programs of the same name; the administrator should copy them to (or symlink them from) a place where those programs are usually found, typically /sbin.

In particular, the basedir/bin/init script suitable as a "stage 1" init program, i.e. the first program run by the kernel (possibly after an initramfs execution). Once this script is copied to, or symlinked from, /sbin/init, the machine will be ready to boot on the new s6-based system.

Boot sequence

When the kernel boots, it may run an initramfs first, but in any case it then runs the basedir/init script, also known as stage 1. This is what happens during stage 1:

initscript is the responsibility of the administrator - it will not be written automatically! It should contain all the necessary initialization sequence to bring up a proper system. When initscript is executed, the machine state is as follows:

There is nothing else. In particular, no filesystem has been mounted yet, including /proc and /sys; and no one-time initialization has been performed. The point of stage 1 is only to make it possible to run initscript with a logging infrastructure and a supervision infrastructure already available, and all the real machine and service initialization should happen in initscript, also known as stage 2.

Shutdown sequence

The examples/ subdirectory of the s6-linux-init package contains an example of /etc/rc.init and /etc/rc.shutdown scripts, suitable for initscript and shutdownscript respectively. Those scripts can practically be used as is if the machine is managed by the s6-rc service manager.

s6-linux-init-maker options

Notes

The difficult parts of running s6-svscan as process 1 are:

The main benefit of s6-linux-init-maker is that it automates those parts. This means that it has been designed for real hardware where the above issues apply. If you are building an init system for a virtual machine, a container, or anything similar that does not have the /dev/console issue or the read-only rootfs issue, you will probably not reap much benefit from using s6-linux-init-maker: you could probably invoke s6-svscan directly as your process 1, or build a script by hand, which would result in a simpler init with less dependencies. Nevertheless, if you prefer using s6-linux-init-maker, it supports this case via the -n option.