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 ] \
       [ -C ] \
       [ -B ] \
       [ -S ] \
       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:

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. Of course, the scripts are editable, so advanced users can run s6-linux-init-maker to create a basic template, and then make their own modifications.

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 parts. Whether it is used for real hardware or for containers, s6-linux-init-maker gives you a turnkey init system that frees your mind from the details of getting a s6 supervision tree running prior to everything else.