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 that is suitable as an /sbin/init program as well as all the necessary files that this script needs to properly boot and bring up a full s6 infrastructure.

s6-linux-init-maker only writes scripts. At boot time, these scripts will call commands provided by other skarnet.org packages such as execline and 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. If it is not the case, the system will fail to boot.

Interface and usage

     s6-linux-init-maker \
       [ -c basedir ] \
       [ -u log_user ] \
       [ -G early_getty ] \
       [ -1 ] \
       [ -L ] \
       [ -p initial_path ] \
       [ -m initial_umask ] \
       [ -t timestamp_style ] \
       [ -d slashdev ] \
       [ -s env_store ] \
       [ -e initial_envvar ] ... \
       [ -q finalsleeptime ] \
       [ -D initdefault ] \
       [ -n | -N ] \
       [ -f skeldir ] \
       [ -U utmp_user ] \
       dir

Once the command has been run and dir has been created, there are a few manual steps to take:

  1. s6-linux-init-maker has copied some scripts from the /etc/s6-linux-init/skel directory (or the directory you gave as an argument to the --skeldir configure option at build time) to the dir/scripts directory. You should edit these scripts and adapt them to your use case. (Or you could edit the skeleton scripts before running s6-linux-init-maker.) The scripts are:
  2. Copy the dir directory to the place declared as basedir (/etc/s6-linux-init/current by default). 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.
  3. Back up your /sbin. Then copy, link or symlink all the scripts and symlinks in the basedir/bin directory into /sbin. In particular, the basedir/bin/init script should be accessible as /sbin/init.

Boot sequence

When the kernel boots, it may run an initramfs first, but in any case it then runs the /sbin/init script, also known as stage 1. This script is just an execution of the s6-linux-init program with some command-line options that are directly transferred from the s6-linux-init-maker invocation. Refer to the s6-linux-init man page to know exactly what it does.

s6-linux-init-maker options

Organization of the created directory

If s6-linux-init-maker returns successfully, dir contains data that will be used at boot time. (Actually, basedir will be used at boot time, not dir. Do not forget to copy dir to basedir once you have checked you are happy with what s6-linux-init-maker has created.)

This boot-time data is made of several subdirectories:

If s6-linux-init has been built with utmps support, some more directories may exist:

Notes

A directory created by s6-linux-init-maker is only valid on the machine it has been created on. Pre-creating init directories for other machines is not supported.

After booting, basedir should remain untouched during the lifetime of the machine, because the machine state change and shutdown procedures will look for data in basedir. New invocations of s6-linux-init-maker should use a different basedir.

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

The main benefit of s6-linux-init-maker is that it offers transparent compatibility while automating the tricky technical part. That means that s6-linux-init-maker has been designed for real hardware, or at least full-fledged Linux systems, where the above issues apply. If you are building an init system for a container, or anything similar that does not have the /dev/console issue, the read-only rootfs issue, or the need for sysvinit compatibility, 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.