Skip to content

Commit 84fd319

Browse files
committed
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 <[email protected]>
1 parent 994e51e commit 84fd319

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

doc/config.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -201,38 +201,52 @@ order, and `swapoff` is called.
201201

202202
### Runlevels
203203

204+
Finit supports runlevels, but unlike other init systems runlevels are
205+
declared per service/run/task/sysv command. When booting up a system
206+
Finit pass through three phases:
207+
208+
1. Setting up the console, parsing any command line options, and other
209+
housekeeping tasks like mounting all filesystems, and calling `fsck`
210+
2. Starting all run/task/services in runlevel S, then waiting for all
211+
services to have started, and all run/tasks to have completed
212+
3. Go to runlevel 2, or whatever the user has set in the configuration
213+
214+
Available runlevels:
215+
204216
- ` S`: bootStrap
205217
- ` 1`: Single user mode
206218
- `2-5`: traditional multi-user mode
207219
- ` 6`: reboot
208220
- `7-9`: multi-user mode (extra)
209221
- ` 0`: shutdown
210222

211-
Runlevels are declared per service/run/task/sysv command. Starting in
212-
runlevel S (bootStrap), usually only for tasks supposed to run once at
213-
boot, and services like `syslogd`, which you need to start and run
214-
throughout the whole time your system is up.
223+
Runlevel S (bootStrap), is for tasks supposed to run once at boot, and
224+
services like `syslogd`, which need to start early and run throughout
225+
the lifetime of your system.
215226

216-
Before `S` is started, however, Finit performs a lot of housekeeping
217-
tasks like mounting all filesystems, calling `fsck` if needed, and
218-
making sure the everything is OK.
227+
Example:
219228

220229
task [S] /lib/console-setup/console-setup.sh
221230
service [S12345] env:-/etc/default/rsyslog rsyslogd -n $RSYSLOGD_ARGS
222231

223-
After runlevel S, Finit proceeds to runlevel 2. This can be changed in
224-
`/etc/finit.conf` using the `runlevel N` directive, or by a script
225-
running in runlevel S that calls, e.g., `initctl runlevel 9`. The
226-
latter is useful if startup scripts detect problems outside of Finit's
227-
control, e.g., critical services/devices missing or hardware problems.
228-
229-
Before starting the services in runlevel 2, Finit first stops everything
230-
that is not allowed to run in 2, and then brings up networking.
231-
Networking is expected to be available in all runlevels except: S, 1
232-
(single user level), 6, and 0. Networking is enabled either by the
233-
`network script` directive, or if you have an `/etc/network/interfaces`
234-
file, Finit calls `ifup -a` -- at the very least the loopback interface
235-
is brought up.
232+
When bootstrap has completed, Finit moves to runlevel 2. This can be
233+
changed in `/etc/finit.conf` using the `runlevel N` directive, or by a
234+
script running in runlevel S that calls, e.g., `initctl runlevel 9`.
235+
The latter is useful if startup scripts detect problems outside of
236+
Finit's control, e.g., critical services/devices missing or hardware
237+
problems.
238+
239+
Each runlevel must be allowed to "complete". Meaning, all services in
240+
runlevel S must have started and all run/tasks have been started and
241+
collected (exited). Finit waits 120 seconds for all run/tasks in S to
242+
complete before proceeding to 2.
243+
244+
Finit first stops everything that is not allowed to run in 2, and then
245+
brings up networking. Networking is expected to be available in all
246+
runlevels except: S, 1 (single user level), 6, and 0. Networking is
247+
enabled either by the `network script` directive, or if you have an
248+
`/etc/network/interfaces` file, Finit calls `ifup -a` -- at the very
249+
least the loopback interface is brought up.
236250

237251
> [!NOTE]
238252
> 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.
651665

652666
**Syntax:** `runlevel <N>`
653667

654-
The system runlevel to go to after bootstrap (S) has completed. `N`
655-
is the runlevel number 0-9, where 6 is reserved for reboot and 0 for
656-
halt.
668+
The system runlevel to go to after bootstrap (S) has completed. `N` is
669+
the runlevel number 0-9, where 6 is reserved for reboot and 0 for halt.
670+
Completed in this context means all services have been started and all
671+
run/tasks have been started and collected.
657672

658673
It is recommended to keep runlevel 1 as single-user mode, because
659674
Finit disables networking in this mode.

0 commit comments

Comments
 (0)