doc: clarify what is required for moving from runlevel S to 2

All run/tasks must complete before Finit moves to runlevel 2.  This
critical piece of information has mysteriously been missing from the
documentation since the start.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2025-03-27 10:23:11 +01:00
1 parent 994e51e34f
commit 84fd3196b0
1 file changed
+37 -22
+37 -22
View File
@@ -201,6 +201,18 @@ order, and `swapoff` is called.
### Runlevels ### Runlevels
Finit supports runlevels, but unlike other init systems runlevels are
declared per service/run/task/sysv command. When booting up a system
Finit pass through three phases:
1. Setting up the console, parsing any command line options, and other
housekeeping tasks like mounting all filesystems, and calling `fsck`
2. Starting all run/task/services in runlevel S, then waiting for all
services to have started, and all run/tasks to have completed
3. Go to runlevel 2, or whatever the user has set in the configuration
Available runlevels:
- ` S`: bootStrap - ` S`: bootStrap
- ` 1`: Single user mode - ` 1`: Single user mode
- `2-5`: traditional multi-user mode - `2-5`: traditional multi-user mode
@@ -208,31 +220,33 @@ order, and `swapoff` is called.
- `7-9`: multi-user mode (extra) - `7-9`: multi-user mode (extra)
- ` 0`: shutdown - ` 0`: shutdown
Runlevels are declared per service/run/task/sysv command. Starting in Runlevel S (bootStrap), is for tasks supposed to run once at boot, and
runlevel S (bootStrap), usually only for tasks supposed to run once at services like `syslogd`, which need to start early and run throughout
boot, and services like `syslogd`, which you need to start and run the lifetime of your system.
throughout the whole time your system is up.
Before `S` is started, however, Finit performs a lot of housekeeping Example:
tasks like mounting all filesystems, calling `fsck` if needed, and
making sure the everything is OK.
task [S] /lib/console-setup/console-setup.sh task [S] /lib/console-setup/console-setup.sh
service [S12345] env:-/etc/default/rsyslog rsyslogd -n $RSYSLOGD_ARGS service [S12345] env:-/etc/default/rsyslog rsyslogd -n $RSYSLOGD_ARGS
After runlevel S, Finit proceeds to runlevel 2. This can be changed in When bootstrap has completed, Finit moves to runlevel 2. This can be
`/etc/finit.conf` using the `runlevel N` directive, or by a script changed in `/etc/finit.conf` using the `runlevel N` directive, or by a
running in runlevel S that calls, e.g., `initctl runlevel 9`. The script running in runlevel S that calls, e.g., `initctl runlevel 9`.
latter is useful if startup scripts detect problems outside of Finit's The latter is useful if startup scripts detect problems outside of
control, e.g., critical services/devices missing or hardware problems. Finit's control, e.g., critical services/devices missing or hardware
problems.
Before starting the services in runlevel 2, Finit first stops everything Each runlevel must be allowed to "complete". Meaning, all services in
that is not allowed to run in 2, and then brings up networking. runlevel S must have started and all run/tasks have been started and
Networking is expected to be available in all runlevels except: S, 1 collected (exited). Finit waits 120 seconds for all run/tasks in S to
(single user level), 6, and 0. Networking is enabled either by the complete before proceeding to 2.
`network script` directive, or if you have an `/etc/network/interfaces`
file, Finit calls `ifup -a` -- at the very least the loopback interface Finit first stops everything that is not allowed to run in 2, and then
is brought up. brings up networking. Networking is expected to be available in all
runlevels except: S, 1 (single user level), 6, and 0. Networking is
enabled either by the `network script` directive, or if you have an
`/etc/network/interfaces` file, Finit calls `ifup -a` -- at the very
least the loopback interface is brought up.
> [!NOTE] > [!NOTE]
> When moving from runlevel S to 2, all run/task/services that were > When moving from runlevel S to 2, all run/task/services that were
@@ -651,9 +665,10 @@ stanzas can share the same rlimits if they are in the same .conf.
**Syntax:** `runlevel <N>` **Syntax:** `runlevel <N>`
The system runlevel to go to after bootstrap (S) has completed. `N` The system runlevel to go to after bootstrap (S) has completed. `N` is
is the runlevel number 0-9, where 6 is reserved for reboot and 0 for the runlevel number 0-9, where 6 is reserved for reboot and 0 for halt.
halt. Completed in this context means all services have been started and all
run/tasks have been started and collected.
It is recommended to keep runlevel 1 as single-user mode, because It is recommended to keep runlevel 1 as single-user mode, because
Finit disables networking in this mode. Finit disables networking in this mode.