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 Warning

Warning: Please read the whole warning

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. For example, if you install openvpn, you also need to install openvpn-openrc.

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.

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), wicd-openrc, networkmanager-openrc, networkmanager-elogind, 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>

In the case of PulseAudio, you'll need to edit /etc/pulse/client.conf and remove the autospawn = no line (source), and it should look something like this:

; default-sink =
; default-source =
; default-server =
; default-dbus-server =

; autospawn = yes
; daemon-binary = /usr/bin/pulseaudio
; extra-arguments = --log-target=syslog

; cookie-file =

; enable-shm = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB 

; auto-connect-localhost = no
; auto-connect-display = no

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

OpenRC is available at PCR. It can be installed as:

# pacman -S base-openrc

You have a few choices you can make, or accept the defaults of what's in base-openrc.

Underneath it, OpenRC needs a separate /sbin/init program. Compatible init programs provide the openrc-pid1 pseudo-package. You can get an up-to-date list of providers by running expac -S '%n %P ' | sed -n '/ openrc-pid1[= ]/s/ .*//p'. Currently the options are:

After installing an openrc-pid1 provider, OpenRC should boot by default instead of systemd. Note that it will boot to a command line, as the service for a graphical display manager has not yet been installed.

You also have a choice of udev implementations to set up hardware devices. You can get an up-to-date list of choices by running expac -S '%n %P ' | sed -n '/ udev[= ]/s/ .*//p'. Currently the options are:

  • eudev (the base-openrc default): Gentoo's fork of udev
  • systemd-udev: The traditional udev implementation
  • notsystemd-udev: The traditional udev implementation, but compiled differently

On installing any -openrc package, one may get messages like:

run 'rc-update add cronie default'
run 'rc-update add dbus default'

Running these command(s) adds the service(s) to the specified runlevels. For example on running:

# rc-update add dbus default

The dbus service would be added to the default runelevel and would automatically be started at boot.

dbus (system message bus) and cronie (for cron) are some common services that can be enabled.

3.1 openrc-desktop

The openrc-desktop package group can be used to install most software needed for desktop environments:

# pacman -S openrc-desktop

Also you need to install polkit-elogind to gain enough desktop privileges for operations like shutdown, mounting usb device:

# pacman -S polkit-elogind

Then enable elogind:

rc-update add elogind default

4 Configuration

4.1 Daemons often required

Once you migrate to OpenRC, you might need to add dbus, or lvm2 etc. There is the procedure for lvm2-openrc :

# rc-update add lvm boot

For cryptsetup-openrc :

# rc-update add dmcrypt boot

For dbus-openrc :

# rc-update add dbus default

For alsa-utils-openrc :

# rc-update add alsasound default

For cronie-openrc :

# rc-update add cronie default

On each package containing an OpenRC daemon, you will have have this message :

      ==> rc 'rc-update add ... default'

4.2 Hostname

OpenRC has its configuration in /etc/conf.d/, in order to have your hostname, edit /etc/conf.d/hostname:

# nano /etc/conf.d/hostname

And replace localhost with the name that you want

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

4.3 NetworkManager settings

NetworkManager is installed with the package networkmanager-openrc, you need to enable the software at boot:

# rc-update add NetworkManager default

In order to not change the computer's hostname when you're connecting to Internet (provided by dhcp), uncomment the part [keyfile] in the file /etc/NetworkManager/NetworkManager.conf as follow :

# Static hostname
[keyfile]
hostname=**Your hostname**

For NetworkManager to work correctly in OpenRC, make sure that /etc/hostname has the same localhost as in /etc/conf.d/hostname. Optionally, you can safely remove /etc/hostname

Tip: If you are using elogind, remember to use networkmanager-elogind

4.4 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, is you are using X11, this won't affect your graphical environment

4.5 Launch X11 without root access

As logind only functions if the system is booted with systemd as PID 1, Xorg.wrap can't start X without root rights and fails. [source]

The solution is to CREATE a file with contents in /etc/X11/Xwrapper.config :

# Xorg.wrap configuation file
needs_root_rights = yes 

4.6 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 comme suit :

DISPLAYMANAGER="lxdm"

Enable the daemon xdm :

# rc-update add xdm default

Note that some DMs like xfce4-session don't work well.

4.7 Autologin to virtual console

Edit the agetty_options variable in /etc/conf.d/agetty.ttyX and add --autologin <your_username> --noclear (source [[1]][[2]]). X represents the tty number.

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 Tips & Tricks

6.1 Nonsystemd repository

Nonsystemd is a repository with packages without systemd support, which is useful for non-systemd users for obvious reasons. There it is the your-initfreedom package, which will remove packages made for systemd (see its blacklist here)

Warning: When transitioning from the [libre] filesystem package to the [nonsystemd] one, it can possibly replace your fstab, passwd, groups and other files in /etc. Login as root before upgrading, and then copy the .pacsave files as the normal files without such extension.

7 Troubleshooting

7.1 Sysctl.conf is missing

You can encouter an issue if /etc/sysctl.conf is missing. To fix this, you need to create the file:

# touch /etc/sysctl.conf

7.2 /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

7.3 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

7.4 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

7.5 The system can't shutdown correctly

Since /sbin/init was replaced with openrc-init, shutdown was replaced with openrc-shutdown, Consolekit doesn't work correctly and you need to use elogind instead. Check the new OpenRC#openrc-desktop session for detail. If you use startx to start your desktop, you also need to modify ~/.xinitrc: for xfce4, for example, replace exec ck-launch-session startxfce4 to startxfce4.

7.6 Unable to mount Android phone

A Temporary fix: Install "android-udev" which supplies /usr/lib/udev/rules.d/51-android.rules. Add GROUP="uucp" in against your phone in /etc/udev/rules.d/51-android.rules. Also you need to add your username to uucp group: gpasswd -a username uucp. Reboot system to take effect. [source]

7.7 dbus doesn't start

Sometimes the dbus service won't start due to missing dbus user. This can be solved by doing:

# groupadd -r -g 81 dbus
# useradd -r -u 81 -g 81 -s /sbin/nologin dbus

And restart with rc-service. Also make sure you are using dbus-elogind.