S6-LINUX-INIT(8)

NAME
s6-linux-init - a stage 1 init

SYNOPSIS
s6-linux-init [-c basedir] [-p initial_path] [-s env_store] [-m umask] [-d slashdev] [-D initdefault] [-n | -N] [-C] [-B] args...

DESCRIPTION
s6-linux-init is a program that is meant to run as pid 1, as a stage 1 init: it performs the necessary early system preparation and exec(3) s into s6-svscan(8).

If s6-linux-init isn't pid 1, it exec(3) s into s6-linux-init-telinit(8) with the same arguments.

Else, it performs some early preparation, spawns a process that will run the rc.init script, then exec(3) s into s6-svscan(8).

  Early preparation
When booting a system, s6-linux-init performs the following operations:

•   It prints a banner to /dev/console.

•   It chdir(2) s to /.

•   It sets the umask to initial_umask.

•   It becomes a session leader.

•   It mounts a devtmpfs on slashdev, if requested.

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

•   It unmounts /run ( or the directory you have given to the ‘--tmpfsdir’ configure option at package build time), just in case; then it creates a tmpfs on it. Alternatively, it remounts /run, or does not touch it at all.

•   It copies the whole basedir/run-image hierarchy to /run ( or your chosen tmpfsdir).

•   It reads the initial environment from basedir/env.

•   If required, it stores the kernel environment into env_store.

•   It performs “the fifo trick”, i.e. 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 s6-svscan(8) is executed).

•   It forks a child.

    •   The child scans the kernel command line to find a suitable runlevel ( ‘default’, ‘2’, ‘3’, ‘4’, or ‘5’). If it doesn't find any kernel command line argument that defines a runlevel, it uses initdefault.

    •   The child becomes a session leader.

    •   The child blocks until the catch-all logger runs.

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

•   It traps the ctrl-alt-del keyboard combination.

•   It exec(3) s into s6-svscan(8) with /run/service as its s6-scan-directory(7) ( or tmpfsdir/service).

    •   s6-svscan(8) spawns the early services that are defined in basedir/run-image/service, and have been copied into /run/service ( or tmpfsdir/service).

    •   One of those early services is ‘s6-svscan-log’, which is the catch-all logger. When this service is up, s6-linux-init' s child unblocks.

    •   The child exec(3) s into basedir/scripts/rc.init. The first argument to rc.init is the chosen runlevel. The kernel command line, as given by the kernel to s6-linux-init ( i.e. without the ‘key=value’ arguments, which were passed into s6-linux-init' s environment and were stored into env_store), makes for the rest of the arguments given to rc.init.

By the time rc.init runs, s6-svscan(8) is running as pid 1 and has spawned its early services — at least the catch-all logger, and the other services, including the early getty if it has been defined, are started in parallel and will be ready instantly. rc.init can then perform stage 2 of the initialization process, i.e. the handoff to the service manager.

The s6-linux-init binary is not meant to be called directly, or be linked to /sbin/init directly, because it takes command-line options. Instead, after an s6-linux-init-maker(8) invocation, the bin/ subdirectory of the target will contain a script called init, which exec(3) s into s6-linux-init with the appropriate command-line options, and is suitable as an /sbin/init program. The bin/ subdirectory should be copied by the administrator into /sbin for full interface compatibility with sysvinit.

OPTIONS
These options should exactly mirror the options with the same name that have been given to s6-linux-init-maker(8). If there is a discrepancy, the system might not boot.

-c basedir
    Read all its initialization data from basedir. If the data has not indeed been copied to basedir, the system will not boot.

-p initial_path
    The initial value for the PATH environment variable.

-s env_store
    The place where to dump kernel environment variables.

-m initial_umask
    The initial file umask.

- slashdev
    Mount a devtmpfs on slashdev. By default, no such mount is performed — it is assumed that a devtmpfs is automounted on /dev at boot time by the kernel.

-D initdefault
    The initial runlevel to boot to, if it isn't overridden by the kernel command line. This is only given as a first argument to rc.init. Default is ‘default’.

-n  Instead of unmounting /run and mounting a tmpfs on it, just remount /run.

-N  Do not touch /run at all.

-C  Run in a container. This option modifies a few of the operations described in Early preparation, to accommodate running in a container instead of on real hardware. For instance: it does not scan the command line for a specific runlevel, it does not trap ctrl-alt-del, and before anything else it waits for its descriptor 3, if present, to close. ( Docker uses this fd 3 mechanism as synchronization between the Docker daemon and the container's init).

-B  Do not run the catch-all logger. This option removes the catch-all-logger-related operations from the list in Early preparation; s6-linux-init will not redirect output descriptors, and will use a different synchronization mechanism to ensure rc.init only runs when s6-svscan(8) is ready.

EXIT STATUS
s6-linux-init never exits. It spawns the rc.init script and exec(3) s into s6-svscan(8), which runs forever until the machine stops or reboots.

SEE ALSO
s6-linux-init-echo(1), s6-linux-init-overview(7), s6-linux-init-why(7), s6-linux-init-hpr(8), s6-linux-init-logouthookd(8), s6-linux-init-maker(8), s6-linux-init-nuke(8), s6-linux-init-shutdown(8), s6-linux-init-shutdownd(8), s6-linux-init-telinit(8), s6-linux-init-umountall(8)

This man page is ported from the authoritative documentation at: https://skarnet.org/software/s6-linux-init/s6-linux-init.html

AUTHORS
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)