A 10.000ft overview:
init
as PID 1
init
runs a script or interactive shell
init
spawns getty
and acts as default reaper
A 1.000ft view:
/sbin/init
init
acts according to its arguments passed by the bootloader through the kernel
init
starts /etc/rc
or the single user shell
/etc/rc
orders the rc.d scripts with rcorder
getty
is supervised
To continue our discussion we need a few definitions.
The process running with PID 1. If it exits for any reason the kernel panics.
Services can have hard forward dependencies.
The kernel searches the init_path
kenv for potential locations of init
It defaults to /sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init
.
Changing init_path
from the loader prompt is enough to switch back and forth.
exec(2)
is allowed
./run
script: Becomes the service
./finish
script: Clean up after the service
./env/
dir: Contains one file per environment variable
./notification-fd
file: Used for readiness notification
./event/
dir: Each watching process puts a pipe here
./supervise/
dir: Contains the control fifo and service state
./log/
dir: Not used by s6-rc
s6-rc-compile compiled source...
./type
: Either bundle, longrun or oneshot
Atomics (longrun, oneshot):
./dependencies
: A list of forward dependencies, loops are prohibited
Oneshots:
./up
: Perform the state transition
./down
: Reverse the state transition
s6-rc-init -p default. /run/service
s6-rc-init
has to be called to initialize the s6-rc service manager
s6-rc-init
uses /etc/s6-rc/compiled by default
/etc/s6-rc/.compiled-$UUID
and update symlink
s6-rc-update [ -f convfile ] newdb
hostid → hostuuid
mysql → mariadb restart
# Prepare a writable file system
echo "tmpfs /run tmpfs rw,mode=0755,size=${RUN_SIZE} 0 0" |
env PATH_FSTAB=/dev/stdin mount -a
s6-hiercopy /etc/run /run
# As soon as loging is available
s6-rc-init -p default. /run/service
s6-rc change "enabled"
# Become the true init process
exec s6-svscan -s /run/service
I would like to thank Laurent Bercot for writing s6-rc and testing it more than one platform.