# OpenRC

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

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

## Installation

OpenRC is available in the AUR.

### Method A (apg way)

You can choose to install either openrc or openrc-git package. 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.

### Method B (artoo way)

Here the basic packages are openrc-base and eudev-openrc.

eudev is a fork of system-udev with the goal of obtaining better compatibility with existing software such as OpenRC.

To use OpenRC with the udev from systemd, do not install the eudev-openrc package as it conflicts with systemd. This way one can easily switch between systemd and openrc.

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

## Configuration

### apg 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 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 `/etc/conf.d` directory, and the `/etc/rc.conf` file is used for configuration.

Most of the later examples use `/etc/openrc/*`; for artoo method use the above specified directories and files.

Here udev is enabled by default.

### Common

For detailed instructions on configuring OpenRC, read the man pages, visit the gentoo guide and the gentoo wiki.

### Network

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

dhcpcd is enabled by default.

For network configuration, look at the `/etc/conf.d/net` file.

Out of the box it uses netifrc, which defaults to dhcpcd if not specified differently in `/etc/conf.d/net`

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

For more info, look at Gentoo documentation

Other options are available, like networkmanager-openrc and connman-openrc from the AUR.

#### General

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

### Logging

#### syslog-ng

If you use syslog-ng, comment out the following line in `/etc/syslog-ng/syslog-ng.conf`:

    unix-dgram("/run/systemd/journal/syslog")

and add this line instead:

    unix-dgram("/dev/log");

Note: Without making this change syslog-ng will fail to run and as a result nothing will be logged!

#### Boot logging

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

Boot logging is enabled by defualt.

To disable it, comment out the rc_logger="YES" line in `/etc/rc.conf`

### Hostname

OpenRC sets the hostname from `/etc/openrc/conf.d/hostname`.

Here is an example file:

    /etc/openrc/conf.d/hostname

    hostname="myhostname"

### Module autoloading

OpenRC doesn't use /etc/modules-load.d/ folder, instead it uses `/etc/openrc/conf.d/modules`.

add a line like this to that file :

    modules=acpi_cpufreq

### Locale

There is no built-in support for configuring locales in OpenRC. Though, you can configure the settings through the `/etc/locale.conf` file, which is sourced via `/etc/profile.d/locale.sh`.

For details on configuring the locale, take a look here.

## 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 doesn't 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

## 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 (packaged by artoo) is available in the AUR (note that the eudev package conflict with systemd).

The package by artoo enables {e}udev by default, while one has to do it oneself for apg's package.

Besides eudev, one would probably need dbus-nosystemd in order to get dbus working.

There are other nosystemd packages available which may be required as per your setup.

### Troubleshooting

If your unmounted partitions are not being displayed, then that is probably due to gvfs being compiled for systemd; using gvfs-nosystemd may fix it.

If using with a desktop environment, consolekit packages in the AUR may help.

## Comparison with systemd

systemd | OpenRC | Description
--- | --- | ---
`systemctl list-units` | `rc-status` | List running services status
`systemctl --failed` | `rc-status --crashed` | Check failed / crashed units/services
`systemctl --all` | `rc-update -v show` | Display all available units/services
`systemctl {start,stop,restart,status} xyz` | `/etc/openrc/init.d/xyz {start,stop,restart,status}` | {start,stop,restart,status} units/services immediately
`systemctl {enable,disable} xyz` | `rc-update {add,del} xyz` | add or delete a service/unit

These were extracted from this post.

## External Links

- Wikipedia:OpenRC
- Forum thread about OpenRC in Arch
- Blog: OpenRC on Arch Linux
- Blog: Using OpenRC on Arch / Archbang / Manjaro Linux
- Manjaro wiki

Category:

- Boot process