OpenRC - ArchWiki

# OpenRC

Related articles

- init
- init Rosetta

Note: Arch uses systemd by default. If you use OpenRC, please mention so while asking for help.

OpenRC is an rc system maintained by the Gentoo developers. OpenRC is dependency based and works with the system provided init program, normally sysvinit. It is not a replacement for sysvinit.

## Installation

OpenRC is available in the AUR.

### apg's way

You can choose to install either openrc or openrc-git. You will also need to install openrc-arch-services-git (provides service files for use with openrc on arch) and openrc-sysvinit (a slightly patched version of traditional sysvinit). For the sake of compatibility with initscripts, openrc-sysvinit installs the sysvinit init binary as `/usr/bin/init-openrc`.

The packages will be installed under `/etc/openrc` instead of the default location of `/etc`, so that users can switch to initscripts or systemd when desired.

### artoo's way

Here you will need to install openrc-core and the packages in openrc-base.

Some other packages of note are displaymanager-openrc and alsa-utils-openrc (both grouped under the openrc-desktop group), and networkmanager-openrc.

For the list of packages, look at the openrc packages maintained by artoo in the AUR.

A summary as well as the source for these package groups can be found at github.

eudev can also be used as udev provider instead of systemd.

### Difference between the approaches

apg's version:

- uses a special directory `/etc/openrc` so that initscripts-fork can be used instead of OpenRC.
- uses `newnet` for network configuration.
- follows a monolithic pattern, with one package that contains the base openrc system, and another containing the rc scripts

artoo's version:

- uses the default `/etc` directory to maintain compatibility with the Gentoo version (thus initscripts-fork cannot be used.).
- uses `netifrc` for network (Gentoo default).
- are split packages, which are greater in number, but allow more control in modifying the individual components.

## Configuration

For more information on configuring OpenRC, man pages are available; you can also visit the gentoo guide and the gentoo wiki.

See also Init#Troubleshooting.

### Booting

#### apg's way

For booting with OpenRC add `init=/usr/bin/init-openrc` to the kernel line in your bootloader configuration. If you want to switch back to systemd, change it to `init=/usr/lib/systemd/systemd`.

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

It is worth noting that the udev service is not enabled by default. In order to enable it, do:

    # rc-update add udev sysinit

#### artoo's way

OpenRC is booted by default.

To boot with systemd, add `init=/usr/lib/systemd/systemd` to the kernel line in your bootloader configuration.

The files in the `/etc/conf.d` directory are used for configuration.

Here udev is enabled by default.

### Network

See Network configuration for a detailed look at networking in general.

#### apg's way

There are multiple ways to get a network up and running. One way is by configuring 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.

You can also use NetworkManager, dhcpcd or netcfg by enabling the respective services.

#### artoo's way

dhcpcd is enabled by default.

For network configuration, look at the `/etc/conf.d/net` file. By default it uses netifrc, which defaults to dhcpcd if not specified differently in `/etc/conf.d/net`

The dhcpcd-openrc package provides a specific dhcpcd script, not to be confused with netifrc default. It will start `/etc/init.d/dhcpcd`

To use a static route you need to create a symlink of `net.lo` that reflects your device's name:

    ln -s /etc/init.d/net.lo /etc/init.d/net.eth0

See [1] for details.

For having a graphical network manager, networkmanager-openrc can be installed. Other options are available, like connman via connman-openrc.

Other option is netcfg which mimetizes the netctl behaviour (see 1 if you want to enable profiles connection on booting - requires `wpa_actiond`). You could consult the official documentation or old wiki documentation (be aware of consulting version later than 2012-05-13)

### Logging

#### apg's way

See Init#Cron_functionality.

#### artoo's way

Different loggers are available, like syslog-ng-openrc, metalog-openrc, and rsyslog-openrc. These loggers may conflict with each other, hence using only a single logger is recommended.

### Boot logging

#### apg's way

OpenRC's boot logging is disabled by default. To enable it, uncomment the following line in `/etc/openrc/rc.conf`

    #rc_logger="YES"

#### artoo's way

Boot logging is enabled by default. To disable it, comment out the rc_logger="YES" line in `/etc/rc.conf`

Tip: Boot logs are stored in `/var/log/rc.log`

### Hostname

OpenRC sets the hostname from `/etc/openrc/conf.d/hostname` (apg's way) or `/etc/conf.d/hostname` (artoo's way).

It looks like the following:

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

### Module autoloading

OpenRC does not use /etc/modules-load.d/ folder, instead it uses `/etc/openrc/conf.d/modules` (apg's way) or `/etc/conf.d/modules` (artoo's way).

It looks like the following:

    # 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/conf.d/keymaps` and `/etc/conf.d/consolefont` (artoo's way). You can also configure the settings through the `/etc/locale.conf` file, which is sourced via `/etc/profile.d/locale.sh`.

See [2] and Locale for details.

## 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

If you have OpenRC installed under the `/etc/openrc` sysconf directory.

One fix for this is to put

    # 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

### Error about /etc/sysctl.conf not found

It can be created by running as root:

    touch /etc/sysctl.conf

## Using OpenRC with a Desktop Environment

If using OpenRC with a desktop environment, consolekit-openrc and related consolekit packages in the AUR may help.

For more info on consolekit, have a look at the Gentoo wiki and the Manjaro wiki.

### Xfce

The xfce4-session package has been compiled with logind support; xfce4-session-consolekit from the AUR can be used.

For a login manager, lxdm-consolekit (from the AUR), or lightdm (from the repos) could be used.

### KDE

The kdebase-workspace package needs to be recompiled for use with consolekit (kdebase-workspace-consolekit is available from the AUR).

### ALSA

You have to enable `alsa`: `rc-update add alsasound default`

## Using OpenRC with eudev

With OpenRC being used as init system, the role of systemd is reduced to that of a udev provider, and for compatibility reasons.

eudev is a fork of udev started by the Gentoo project, with the goal of isolation from any particular flavor of system initialization, such as systemd or sysvinit.

### Installation

Note: This method may not work with apg's packages.

eudev is available in the AUR. It basically serves a drop-in replacement for the udev provided by systemd.

Three packages are needed in order to install eudev: eudev-systemdcompat, eudev, and eudev-openrc.

The eudev-systemdcompat package conflicts with systemd and libsystemd, and requires the eudev package. upower-pm-utils is an optional dependency.

Note: One may not be able to install the eudev packages directly from the AUR due to conflicts when installing; to circumvent it, eudev (along with eudev-openrc) can be built and added to a local repository, and then eudev-systemdcompat can be built and installed from the AUR using:

    makepkg -di

(-d to ignore build dependencies), which pulls in eudev as package dependency.

After that eudev-openrc can be installed from the local repo created earlier.

upower-pm-utils can be installed for suspend / hibernate support.

### Troubleshooting

If your unmounted partitions are not being displayed, then that is probably due to gvfs being compiled for systemd; using gvfs-nosystemd from the AUR may fix it (probably not required if using eudev-systemdcompat).

Some packages from the offical repos, like xfce4-power-manager, are compiled with the newer upower; for use with upower-pm-utils, they need to be compiled against it (xfce4-power-manager-upower0 and xfce4-power-manager-pmu are available in the AUR).

Probably your net devices will be renamed: from example `wlp1s0` could be renamed to `wlan0`. You have to set your net configuration properly.

Probably, you experiment that the files in `/etc/sysctl.d/` have been disappeared after removing `systemd` package.

## See also

- Wikipedia:OpenRC
- Gentoo wiki
- Forum thread about OpenRC in Arch
- Blog: OpenRC on Arch Linux
- Manjaro wiki

Category:

- Boot process