From 0fbc0bb34dc83dc1efcf33ef099c7e63d6088574 Mon Sep 17 00:00:00 2001 From: Marcello Lamonaca Date: Sun, 20 Jul 2025 12:12:14 +0200 Subject: [PATCH] runit: add notes --- docs/linux/init/runit.md | 21 +++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 22 insertions(+) create mode 100644 docs/linux/init/runit.md diff --git a/docs/linux/init/runit.md b/docs/linux/init/runit.md new file mode 100644 index 0000000..56eb593 --- /dev/null +++ b/docs/linux/init/runit.md @@ -0,0 +1,21 @@ +# [Runit](https://smarden.org/runit/) + +## Boot + + runit performs the system's booting, running and shutting down in three stages: + +- Stage 1: `runit` starts `/etc/runit/1` and waits for it to terminate. The system's one time initialization tasks are done here. + `/etc/runit/1` has full control over `/dev/console` to be able to start an emergency shell in case the one time initialization tasks fail. +- Stage 2: `runit` starts `/etc/runit/2` which should not return until the system is going to halt or reboot; if it crashes, it will be restarted. + Normally, `/etc/runit/2` runs `runsvdir`. +- Stage 3: If `runit` is told to halt or reboot the system, or Stage 2 returns without errors, it terminates Stage 2 if it is running, and runs `/etc/runit/3`. The systems tasks to shutdown and halt or reboot are done here. + + +## Runlevels + +**Runlevels** are stored in `/etc/runit/runsvdir/`. The name of the directory is the name of the runlevel. + +Adding a service to a runlevel is done by linking the service file (usually under `/etc/sv/`) to `/etc/runit/runsvdir/`. + +Switching to a runlevel is done by switching the directory `runsvdir` is runniing in with `runsvchdir `. + diff --git a/mkdocs.yml b/mkdocs.yml index f471a35..3db7a69 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -199,3 +199,4 @@ nav: - System Init: - Systemd: linux/init/systemd.md - OpenRC: linux/init/open-rc.md + - Runit: linux/init/runit.md