Booting FreeBSD

A 10.000ft overview:

Booting FreeBSD with /etc/rc

A 1.000ft view:

Design choices made

Definitions

To continue our discussion we need a few definitions.

Definition: Init Process

The process running with PID 1. If it exits for any reason the kernel panics.

Definition: Process Supervision

s6-talk__1.png

Definition: Service

Services can have hard forward dependencies.

Definition: Service Management

s6-talk__2.png

Finding the init executable

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.

Constrains on PID 1

Working around the constrains of PID 1

s6-svscan

s6-supervise

s6-rc-compile:

s6-rc-compile compiled source...

Atomics (longrun, oneshot):

Oneshots:

Pipelining

s6-talk__3.png

Logging

Preparing the system for s6-rc

s6-rc-init -p default. /run/service

Atomic service database updates

Switching the service database at runtime

s6-rc-update [ -f convfile ] newdb

Booting FreeBSD with s6-rc

# 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

Network configuration

Supervising login sessions

Live demo

Thanks

I would like to thank Laurent Bercot for writing s6-rc and testing it more than one platform.

Conclusion