OpenRC

From ArchWiki
Warning: Arch Linux only has official support for systemd. [1] When using OpenRC, please mention so in support requests.

OpenRC is a service manager maintained by the Gentoo developers. OpenRC is dependency based and works with the system provided init program, normally SysVinit.

Installation

For details on init components, see Init.

Install the openrcAUR package.

From version 0.25 onward, OpenRC provides its own init at /usr/bin/openrc-init. Optionally, you can use other inits from, e.g., busybox. Note that when openrc-init is used, it must be paired with openrc-shutdown, and not the shutdown or reboot commands from other packages, otherwise you will encounter errors.

A basic set of service files are available from the openrc-arch-services-gitAUR package. Other packages may have service files provided outside this package; a search on the AUR is recommended.

To maintain compatibility with initscripts-forkAUR, configuration files are installed to /etc/openrc/.

Booting

For booting with OpenRC, set the init option in the kernel parameters.

To use OpenRC's built-in init, set init=/usr/bin/openrc-init. To use SysVinit set init=/usr/bin/init-openrc.

Note that when using openrc-init, the /etc/inittab file is not used.

Configuration

The /etc/openrc/conf.d directory, and the /etc/openrc/rc.d file is used for configuration.

For general information on configuring OpenRC, see:

For instructions when migrating from systemd, see Init#Configuration.

Services

OpenRC services are enabled by issuing rc-update add service_name runlevel as root. It is recommended to at least enable the following services:

Service name Runlevel Description
udev sysinit Device hot-plugging
alsa default ALSA state
acpid default ACPI events
dbus default Messaging bus
dcron default Scheduling
syslog-ng default System logs
Warning: If using init=/usr/bin/openrc-init in your kernel parameters, you will need to manually enable getty services, otherwise you will be left with no interactive TTYs as stated in the documentation.

If necessary, create services for each wanted getty by creating symbolic links to /etc/openrc/init.d/getty. E.g. for /dev/tty1:

# ln -s /etc/openrc/init.d/agetty{,.tty1}
# rc-update add agetty.tty1 default

This article or section is a candidate for moving to Init#Configuration.

Notes: Not only applicable to OpenRC (Discuss in Talk:OpenRC)

To prevent PAM from attempting to register with systemd after logging into the tty (which can sometimes cause problems, it is safe to remove or comment out the lines mentioning systemd in /etc/pam.d/system-auth.

See also Gentoo:Systemd#Native services.

Network

The network is configured through newnet [2]. Modify the /etc/openrc/conf.d/network file; both the ip (iproute2) and the ifconfig (net-tools) commands are supported. Below is an example configuration using ip.

ip_eth0="192.168.1.2/24"
defaultiproute="via 192.168.1.1"
ifup_eth0="ip link set \$int mtu 1500"

The network service is added to the boot runlevel by default, so no further action is required. See Network configuration for general networking information.

Note: You may also use NetworkManager or dhcpcd by enabling the respective services.

Boot logs

To enable boot logging, uncomment the rc_logger="YES" line in /etc/openrc/rc.conf. When enabled, boot logs are stored in /var/log/rc.log.

Hostname

OpenRC sets the hostname from /etc/openrc/conf.d/hostname. The file looks as follows:

# Set to the hostname of this machine
hostname="myhostname"

Kernel modules

OpenRC uses /etc/openrc/conf.d/modules instead of /etc/modules-load.d. For example:

/etc/openrc/conf.d/modules
# You should consult your kernel documentation and configuration
# for a list of modules and their options.

modules="vboxdrv acpi_cpufreq"

Locale

Keyboard layout can be configured via /etc/openrc/conf.d/keymaps and /etc/openrc/conf.d/consolefont. You can also configure the settings through the /etc/locale.conf file, which is sourced via /etc/profile.d/locale.sh.

See Gentoo:Localization/Guide#Keyboard layout for the console and Locale for details.

Usage

This section draws a parallel between systemd and other init systems.

You can omit the .service and .target extensions, especially if temporarily editing the kernel parameters.

systemd SysVinit OpenRC Description
systemctl list-units rc.d list rc-status List running services status
systemctl --failed rc-status --crashed Check failed services
systemctl --all rc-update -v show Display all available services.
systemctl (start, stop, restart, status) daemon.service rc.d (start, stop, restart) daemon rc-service daemon (start, stop, restart, status) Change service state.
systemctl (enable, disable) daemon.service chkconfig daemon (on, off) rc-update (add, del) daemon Turn service on or off.
systemctl daemon-reload chkconfig daemon --add Create or modify configuration.

Tips and tricks

Quiet booting

To hide boot messages from OpenRC, you can edit /etc/inittab and add --quiet to every openrc command. For further information check with $ openrc -h.

Troubleshooting

Error while unmounting /tmp

When shutting the system down, you might get an error message such as

* Unmounting /tmp ... 
* in use but fuser finds nothing [ !! ]

This can be fixed by adding

no_umounts="/tmp"

to /etc/openrc/conf.d/localmount

Note: This problem occurs only if your tmp is mounted as a tmpfs.

Disabling IPv6 does not work

One option is to add:

# Disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1

in a file with a .conf extension under /etc/openrc/sysctl.d

During shutdown remounting root as read-only fails

If the above happens, edit the /etc/openrc/init.d/mount-ro file and put:

telinit u

after the following line:

# Flush all pending disk writes now
sync; sync

/etc/sysctl.conf not found

By default, sysctl --system is called to load the sysctl configuration. [3] This includes the /etc/sysctl.conf file, which was removed from Arch. [4]

To prevent a missing file error, create the file:

# touch /etc/sysctl.conf

opentmpfiles-setup failed to start

On booting openrc, you may see lines like these :

* Setting up tmpfiles.d entries ...
chattr: Operation not supported while setting flags on /var/log/journal
chattr: No such file or directory while trying to stat /var/log/journal/%m
chattr: Operation not supported while setting flags on /var/log/journal/remote
[ !! ]
ERROR: opentmpfiles-setup failed to start

This is caused by /usr/lib/tmpfiles.d/journal-nocow.conf using options that are only valid if journal is on a btrfs filesystem.

See https://github.com/OpenRC/opentmpfiles/issues/2 for details

A workaround is to create an empty /etc/tmpfiles.d/journal-nocow.conf to override the settings.

Reverting to systemd

Reverting to systemd should be straightforward in most cases. It is essentially the reversal of migrating to OpenRC, with care placed on the following:

  • Removal of, or otherwise editing, the init= parameter on the kernel command line
  • Replacement of any OpenRC-tailored or no-systemd packages with their stock equivalents

See also