OpenRC

OpenRC is Article description::a dependency-based init system that maintains compatibility with the system provided program, normally located in. It does not function as a replacement for the file. OpenRC is 100% compatible with Gentoo init scripts, which means a solution can be found to run the dozens of daemons in the main Gentoo repository. OpenRC, however, is not designed to be exclusively used by Gentoo Linux and can be used on other distributions and BSD systems.

Features
OpenRC provides a number of features touted as innovative by recent init systems like systemd or upstart (wikipedia), such as:
 * cgroups support,
 * process supervision,
 * parallel startup of services, and
 * hardware initiated initscripts run.

It does this without requiring large layout changes to accommodate radically different designs and dependencies.

OpenRC Busybox integration
Busybox can be used to replace most of the userspace utilities needed by OpenRC (, shell, and other POSIX tools), by using a complete Busybox as shell for OpenRC all the calls that normally would cause a fork/exec would be spared, improving the overall speed. This process is not yet streamlined.

Please note that there are currently many Busybox applets that are incompatible with OpenRC. See for details.

Replacing init
In order to set a specific runlevel from the bootloader the variable  should be used.

busybox
The SysV-init file provided by Gentoo is not compatible with the Busybox.

openrc-init
OpenRC has its own init system called openrc-init. See OpenRC/openrc-init for details.

Daemon supervision
OpenRC has its own process supervisor. See OpenRC/supervise-daemon for details. Alternatively [//skarnet.org/software/s6/ Skarnet's S6] is also supported by OpenRC. See S6 for details.

Busybox specific init.d files
TODO: busybox provides a number of applets that could be used to replace third party software like acpid or dhcp/dhcpcd.

Replacing udev with mdev
See mdev.

Replacing udev with eudev
Older Gentoo installs were using udev as the main provider. Based on it was changed to eudev. However, the rc service is still.

Files

 * The global OpenRC configuration file.
 * The global OpenRC configuration file.

Logging
OpenRC doesn't log anything by default. To log OpenRC's output during boot, uncomment and set the rc_logger option in. The log will be saved at by default.

Network management
OpenRC can be used with one of several network managers or even with none, see Network manager.

Dependency behavior
Changing the default dependencies of init scripts, might be needed to fit more complex setups. See for how to change the default behavior; notice the rc_depend_strict option. In addition, next networking examples show how flexible OpenRC can be.

The SSH service must come up with the internal network, for instance eth0 and never wlan0.
 * Multiple network interfaces (example)

Overrule the "net" dependency from, and refine it to depend on "net.eth0":

The SSH service must start with eth0 (not wlan0) in "default" runlevel, but in "office" runlevel it must start with wlan0 (not eth0).
 * Multiple network interfaces in multiple runlevels (example)

Keep the default:

Make additional symlinks to with the network interface names:

Settings are read from and  now:

Add the dependencies:

In this example net.eth0 and net.wlan0 read their settings from, or depending on the active runlevel. Add all runscripts to the different runlevels:

To switch between "default" runlevel and "office" runlevel without rebooting the computer, change to "nonetwork" runlevel in between. The network interfaces will be stopped this way, and re-read their runlevel specific configuration. This works best when "nonetwork" is a stacked runlevel in both the "default" and "office" runlevels, and the display manager and other non-network services are added to the "nonetwork" runlevel only.

 default runlevel <---> nonetwork runlevel <---> office runlevel 

Selecting a specific runlevel at boot
OpenRC reads the kernel command-line used at boot time, and will start the runlevel specified by the "softlevel" parameter if provided, instead of 'default'.

For instance, you can choose whether to boot into the 'default' or 'nonetwork' runlevels with the following example configuration:

Runlevels
OpenRC can be controlled and configured using, and  commands.

Delete a service from default runlevel, where  is the name of the service to be removed:

Listing
Listing commands do not need to be ran as root.

Use to display all available init scripts and their current runlevel (if they have been added to one):

Running or  will display only the init scripts that have been added to a runlevel.

Alternatively, the command can be used with the    option to view the state of all services:

Named runlevels
OpenRC runlevels are directories living in to create additional runlevels is enough to issue:

Stacked runlevels
Is possible manage variants using.

An usage example for using stacked runlevel on laptop to group networking services based on location is at OpenRC/StackedRunlevel.

Prefix
Gentoo Prefix installs Gentoo within an offset, known as a prefix, allowing users to install Gentoo in another location in the filesystem hierarchy, hence avoiding conflicts. Next to this offset, Gentoo Prefix runs unprivileged, meaning no root user or rights are required to use it.

By using an offset (the "prefix" location), it is possible for many "alternative" user groups to benefit from a large part of the packages in the Gentoo Linux Portage tree. Currently users of the following systems successfully run Gentoo Prefix: Mac OS X on PPC and x86, Linux on x86, x86_64 and ia64, Solaris 10 on Sparc, Sparc/64, x86 and x86_64, FreeBSD on x86, AIX on PPC, Interix on x86, Windows on x86 (with the help of Interix), HP-UX on PARISC and ia64.

OpenRC runscript already support prefix-installed daemons, during the Summer of Code 2012 work will be done to implement full secondary/session daemon behavior to complete the overall feature set provided by Prefix.

OpenRC/Prefix, a tutorial for trying it out.

Hotplug
OpenRC can be triggered by external events, such as new hardware from udev. See OpenRC/Event Driven for details.

Manually recovering crashed services
If you have a process that crashes upon start you will see the following when you go to check it's status.

To remedy this situation you will need to zap the process which in the following example is the docker service.

Automatic respawning crashed services
OpenRC can return state of services to runlevel setting state, to provide stateful init scripts and automatic respawning. What you need is to run (for default runlevel). Crashed services start and manual run services will stop. To prevent this you can run

By default will attempt just to start crashed services, not restart. This сontrolled by rc_crashed_stop (default NO) and rc_crashed_start (default YES) options in.

CGroups support
OpenRC starting with version 0.12 has extended cgroups support. See OpenRC/CGroups for details.

Chroot support
If you find that you are getting

messages attempting to start a service, you may need to run

logind
As some setups require systemd-logind. Elogind can be a suitable replacement as a standalone logind running with OpenRC.

tmpfiles.d
systemd has a special tmpfiles.d file syntax for managing temporary files. provides a tmpfiles.d interpreter for OpenRC.

Both can also be used to manage volatile entries in or.