Void uses the runit(8) supervision suite to run system services and daemons.
Some advantages of using runit include:
- a small code base, making it easier to audit for bugs and security issues.
- each service is given a clean process state, regardless of how the service was started or restarted: it will be started with the same environment, resource limits, open file descriptors, and controlling terminals.
- a reliable logging facility for services, where the log service stays up as long as the relevant service is running and possibly writing to the log.
Each service managed by runit has an associated service directory.
A service directory requires only one file: an executable named
run, which is
expected to exec a process in the foreground.
Optionally, a service directory may contain:
- an executable named
check, which will be run to check whether the service is up and available; it's considered available if
checkexits with 0.
- an executable named
finish, which will be run on shutdown/process stop.
conffile; this can contain environment variables to be sourced and referenced in
- a directory named
log; a pipe will be opened from the output of the
runprocess in the service directory to the input of the
runprocess in the
When a new service is created, a
supervise folder will be automatically
created on the first run.
Most services can take configuration options set by a
conf file in the service
directory. This allows service customization without modifying the service
directory provided by the relevant package.
Check the service file for how to pass configuration parameters. A few services
have a field like
OPTS="--value ..." in their
To make more complex customizations, you should edit the service.
To edit a service, first copy its service directory to a different directory name. Otherwise, xbps-install(1) can overwrite the service directory. Then, edit the new service file as needed. Finally, the old service should be stopped and disabled, and the new one should be started.
A runsvdir is a directory in
/etc/runit/runsvdir containing enabled
services in the form of symlinks to service directories. On a running system,
the current runsvdir is accessible via the
runit-void package comes with two runsvdirs,
singlejust runs sulogin(8) and the necessary steps to rescue your system.
defaultis the default runsvdir on a running system, unless specified otherwise by the kernel command line.
Additional runsvdirs can be created in
To boot a runsvdir other than
default, the name of the desired runsvdir can be
added to the kernel command-line. As an example, adding
single to the kernel command line will boot the
To start, stop, restart or get the status of a service:
# sv up <services> # sv down <services> # sv restart <services> # sv status <services>
<services> placeholder can be:
- Service names (service directory names) inside the
- The full paths to the services.
For example, the following commands show the status of a specific service and of all enabled services:
# sv status dhcpcd # sv status /var/service/*
See sv(8) for further information.
Void Linux provides service directories for most daemons in
To enable a service on a booted system, create a symlink to the service
# ln -s /etc/sv/<service> /var/service/
If the system is not currently running, the service can be linked directly into
# ln -s /etc/sv/<service> /etc/runit/runsvdir/default/
This will automatically start the service. Once a service is linked it will always start on boot and restart if it stops, unless administratively downed.
To prevent a service from starting at boot while allowing runit to manage it,
create a file named
down in its service directory:
# touch /etc/sv/<service>/down
down file mechanism also makes it possible to disable services that are
enabled by default, such as the agetty(8)
services for ttys 1 to 6. This way, package updates which affect these services
- in this case, the
runit-voidpackage - won't re-enable them.
To disable a service, remove the symlink from the running runsvdir:
# rm /var/service/<service>
Or, for example, from the
default runsvdir, if either the specific runsvdir,
or the system, is not currently running:
# rm /etc/runit/runsvdir/default/<service>
To check if a service is working correctly when started by the service supervisor, run it once before fully enabling it:
# touch /etc/sv/<service>/down # ln -s /etc/sv/<service> /var/service # sv once <service>
If everything works, remove the
down file to enable the service.