OpenRC

From ParabolaWiki
Jump to: navigation, search

OpenRC is a dependency based init system that originated in Gentoo, that works on top of an underlying /sbin/init program, such as openrc-init or sysvinit.

It is an alternative to systemd. See Init Systems for a brief comparison of init systems.

1 Overview

Usually, when you install a software requiring an unit file, the base package provides a unit file for systemd, but not for openrc. You will need to add "-openrc" to obtain the unit file for OpenRC, unless it's installed from the Nonsystemd repository. For example, if you install openvpn, you also need to install openvpn-openrc, but dbus from [nonsystemd] has its init script already.

If you migrate a running system from systemd to OpenRC, the command poweroff will probably not work until after you reboot, as it will be the OpenRC version poweroff command, but systemd will still be running. You can work around this by leaving the systemd package installed (it won't be used by OpenRC after the reboot), and running systemctl poweroff, or by simply pressing the hardware power switch.

Some software, like netctl, is made for systemd, and it will not work with OpenRC. If you use netctl, you will need to select an alternative. Options include netifrc (Gentoo ("oldnet") network management), openrc-net (OpenRC ("newnet") network management, still very beta), networkmanager, dhcpcd and others.

2 Groups

Note: It is recommended first to test if everything works well, and then read this and add you users to these groups, if needed

Before Arch migrated to systemd, users had to be manually added to some groups in order to be able to access the corresponding devices. Read more about here.

Make sure your user is on the audio group, you won't have sound otherwise:

usermod -aG audio <your-user>

Same for video, your games might be laggy otherwise:

# usermod -aG video <your-user>

And for webcam:

# usermod -aG optical <your-user>

Also for storage

# usermod -aG storage <your-user>
# usermod -aG disk <your-user>

And for CUPS

# usermod -aG sys <your-user>

You can reinstall Systemd when you want, its dependencies will be reinstalled as well.

3 Basic installation

3.1 Migrating from a Systemd installation

First, enable the Nonsystemd repository, then upgrade your system and install your-initfreedom (this package will conflict with systemd packages), elogind, udev-init-scripts and openrc:

# pacman -Syu your-initfreedom elogind udev-init-scripts openrc

If you are asked to remove systemd-related packages, accept it. You'll also be asked for an OpenRC /sbin/init/ provider. There are currently two options:

openrc-init: The OpenRC /sbin/init provider
openrc-sysvinit: Compatibility package to make OpenRC use sysvinit as it's init

3.2 Base system

Note: If you are not installing from one of the OpenRC Live ISOs, ensure that pacman is subscribed to the nonsystemd package repo before beginning the install process.

To install a base OpenRC system:

# pacstrap /mnt base elogind libelogind udev-init-scripts your-initfreedom

You have a few choices you can make, or accept the defaults. Remember to install a kernel, like linux-libre or linux-libre-lts. Note that although libelogind is pulled by elogind many other packages will try to pull systemd-libs (which is provided by libelogind, but pacman tries to install systemd-libs when libelogind is not explicitly listed), that's why you must specify it even if elogind is installed along. The your-initfreedom package will make sure no systemd packages are installed in your system.

3.3 Desktop system

In addition to the other methods mentioned above, one can install the openrc-desktop package group to get most software and its init scripts needed for desktop environments:

# pacman -S openrc-desktop

4 Configuration

4.1 Daemons often required

Once you migrate to OpenRC, you might need to add some services like NetworkManager, lvm2, etc. Here is the procedure for lvm2-openrc:

# rc-update add lvm boot

For networkmanager (from [nonsystemd]):

# rc-update add NetworkManager default

For cryptsetup-openrc:

# rc-update add dmcrypt boot

For alsa-utils-openrc:

# rc-update add alsasound default

For cronie-openrc:

# rc-update add cronie default

... and so on.

If the package was installed from Nonsystemd, it's likely to have its init script already installed. Core packages, like elogind and dbus, have those services installed and enabled by default.

4.2 Hostname

OpenRC has its configuration in /etc/conf.d/hostname. In order to set your hostname, replace the hostname variable with the name that you want:

hostname="localhost"

It's recommended to remove /etc/hostname if you're migrating from Systemd, as it might cause problems to some software that uses your hostname for some tasks or operations (like NetworkManager).

4.3 Keymap

As the hostname, you need to setup the keymap in the file /etc/conf.d/keymaps :

keymap="us"

If you have an advanced usage of your keymap, you can watch the other functionalities, documented in the comments. You can find all the available keymaps in /usr/share/kbd/keymaps. Then run

# rc-service keymaps restart
Note: This only applies for tty, if you are using X11, this won't affect your graphical environment. For X11, use setkxbmap instead.

4.4 Login display manager

With OpenRC, the DM is launched differently. For example, with lxdm, you need to mention lxdm in the file /etc/conf.d/xdm. If that file does not exist, install the displaymanager-openrc package. To enable LXDM, for example, set the DISPLAYMANAGER variable to:
DISPLAYMANAGER="lxdm"

Regardless of which DM you want to use, ensure that the 'xdm' service is enabled:

# rc-update add xdm default

Note that some DMs like xfce4-session might not work well.

5 Adaptation between systemctl and rc-update

5.1 Add or delete a service

You can add a service using this way :

# rc-update add <service> <runlevel>

And delete it as follow :

# rc-update del <service> <runlevel>

5.2 Services currently running

In order to have a summary of all the daemons running, stopped etc, you can run this command:

rc-status --all

5.3 Stop/Start/Restart a service

To start, stop or restart a service, you need to use rc-service:

# rc-service <service> start

You can start them without needing to add them to a runlevel, but will not be started after rebooting.

6 Troubleshooting

6.1 /usr/lib/rc/cache doesn't exist

If you have this error when you shutdown the computer:

WARNING: /usr/lib/rc/cache is not writable!

The solution is to create the folder:

# mkdir /usr/lib/rc/cache

6.2 Swap isn't enabled

Systemd used to mount the swap automatically, you need to manually add the swap in /etc/fstab as follow :

# /dev/sda2
UUID=0c3e9434-bc5c-461c-a5e4-4e9fe5f9a149	swap	swap	sw	0	0

6.3 tmpfs isn't present

As the swap, systemd automatically mounts the tmpfs. Add it manually in /etc/fstab :

tmpfs		/tmp		tmpfs   nodev,nosuid          	0  	0