User:Zatherz

From ArchWiki

This page contains many tutorials on using Arch with OpenRC.

Replacing Systemd with OpenRC and Eudev

For all you Veteran Unix Admins (and me ;)) I wrote this tutorial to help you replace systemd with OpenRC. Let's go! Please do not make Archuan after reading this ;)

Step 1: Are you sure?

Before you change your init, you need to ask yourself "Do you really want that?". Changing your init may break many things that were working just fine before and you may find yourself being on your own sometimes when trying to install OpenRC and Eudev if you do something wrong or your setup is very different. Whether you hate Lennart, love Gentoomen's toys or just want to play around with your system - those are valid reasons. Please remember that no one takes responsibility for the actions you take following this tutorial. Please note that even after this tutorial you will end up with still having a ~0,3MiB libsystemd. It does pretty much none when your init is not systemd and is very tiny (exactly 356KiB). Removing this library or replacing it with the stubified "nosystem" breaks many applications including X or syslog-ng.

Step 2: Install OpenRC alongside Systemd

Before you want to remove systemd completely, you have to get a working OpenRC installation. There are two ways to install OpenRC on Arch. One is called the "apg's way" and the other is the "artoo's way". Both names come from the maintainers of the specific AUR packages (apg and artoo). Artoo maintains more modular packages and his OpenRC package includes udev scripts by default, which is why we'll be going for that. You first want to get and install cower or another AUR helper from AUR unless you want to manually use the web interface.

So, let's start. OpenRC is not a replacement for sysvinit, so you have to install it first. Get sysvinit from AUR, build it and install:

$ cower -d sysvinit
$ cd sysvinit
$ makepkg
$ sudo pacman -U ./sysvinit*.pkg.tar.xz

Now time for OpenRC. Grab openrc-core from the AUR, build and install it:

$ cower -d openrc-core
$ cd openrc-core
$ makepkg
$ sudo pacman -U ./openrc-core*.pkg.tar.xz

Better don't reboot now if you don't want to have no internet connection. To get an internet connection you need to configure your network. The methods vary if you use wired ethernet connection or wireless internet connection. I will describe both. The Gentoo Handbook greatly explains how to configure the network in OpenRC. Most of the instructions here will be partially or fully taken from it.

To make OpenRC know about your network interface, be it wired or wireless, you first have to symlink /etc/init.d/net.<INTERFACE DEVICE> to /etc/init.d/net.lo. You can find the name of the device by issuing:

$ ip link list


On your system with systemd's udev, wireless interfaces will most probably show up as wlpXsX and wired - enpXsX., where X are numbers. Find the correct one and execute:

# cd /etc/init.d
# ln -s net.lo net.DEVICE

Of course replace DEVICE with the name of your wired interface, for example enp1s7.


Configuring wired internet connection

Now that OpenRC knows about this interface you need to configure it. Every network interface configuration is done in /etc/conf.d/net. Open this file in a text editor now. It should be empty. Here's a sample configuration taken directly from the Gentoo Handbook mentioned before with minimal modifications:

# For DHCP
config_DEVICE="dhcp"

# For static IP using CIDR notation
config_DEVICE="192.168.0.7/24"
routes_DEVICE="default via 192.168.0.1"
dns_servers_DEVICE="192.168.0.1 8.8.8.8"

# For static IP using netmask notation
config_DEVICE="192.168.0.7 netmask 255.255.255.0"
routes_DEVICE="default via 192.168.0.1"
dns_servers_DEVICE="192.168.0.1 8.8.8.8"

As before you have to replace DEVICE with the network interface. You also have to choose ONE of these configurations. The first one is for DHCP. It will dynamically fetch your IP. The second and third define static IPs in different notations. You'll most probably want the first one, but depending on your network configuration you may want one of the other. I expect you to know this already, as dang it, you're using Arch man! You're expected to know things.

Configuring wireless network

Wireless network configuration in OpenRC is also easy. There are two ways, one using wpa_supplicant and another one using wireless-tools. Wireless-tools doesn't support WPA-only access points. Wpa_supplicant is therefore a better way and I will focus only on it. Install wpa_supplicant (if you have not already) and open the /etc/conf.d/net file in a text editor. It should be empty. Here's an example of a configuration file, taken from the Gentoo Handbook:

# Prefer wpa_supplicant over wireless-tools
modules="wpa_supplicant"

# It's important that we tell wpa_supplicant which driver we should
# be using as it's not very good at guessing yet
wpa_supplicant_DEVICE="-Dnl80211 -cCONFIGURATION"

Substitute DEVICE with the interface name. I chose the nl80211 driver as if I recall correctly it works on pretty much every card. If your network card doesn't work with nl80211, you can try searching on the web for which driver to use with it. Replace CONFIGURATION with the name of the file you will create in a moment.

That's not the end of configuration though. You have to configure wpa_supplicant itself. Head over to /etc/wpa_supplicant and create a file with a .conf extension. This is the name you have to replace CONFIGURATION with in /etc/conf.d/net. You can call it whatever you want. Open the /etc/conf.d/net file and put the name of the created file after the -c option in the wpa_supplicant line, then close it, open the file you created and fill it with this data:

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
network={
        ssid="SSID"
        psk="PASSWORD"
        priority=5
}

Replace SSID with the SSID of the network and PASSWORD with its password. If you want to learn about how you can hide the password or what the other options do, feel free to head over to the Gentoo Handbook which is a great resource when you ever get stuck with OpenRC.


Now that your wired/wireless interface is configured, it's time to enable it so that it will autostart on boot:

# rc-update add net.DEVICE default

Substitude {{ic|DEVICE} with the interface name.

Make sure everything is ok, that there are no typos and that everything is done exactly how I told you to do it there. Remember that if you get it wrong, you will not have any other chance than use another system to get internet access to eventually fix the one on your Arch system. If you're completely sure you're OK, then it's time to reboot.

# reboot

On the next boot you should see a friendly message:

OpenRC <version> is starting Arch Linux

Along with a few lines of output from services.

Please be aware that you may get one or two errors on the boot-up talking about /etc/sysctl.conf. The error comes from the fact that artoo's package does not create this file by default. So if you get this error, just execute this command after logging in:

# touch /etc/sysctl.conf

It will create an empty /etc/sysctl.conf which should solve the aforementioned errors. Now is the time to check the internet connection.

As your internet connection should autostart on boot, just ping some site you know is online:

$ ping google.pl

If ping responds with unknown host, then you either did not properly configure your network or just didn't enable it before. Try starting it:

# rc-service net.DEVICE start

If it prints errors, then you have most probably wrongly configured it. No matter if it printed errors or not, try to ping some site you know is online again:

$ ping google.pl

If it successfully sends packets, look at the IP. If it starts with something like 192.168, then your network is misconfigured. If it does not starts with very different numbers than 192.168, then enable the service so that it will start on boot:

# rc-update add net.DEVICE default

Taa-daa! You just successfully booted your system with OpenRC. Nice! Now on the next part, where we will do actual business with setting up the bootup and services. If you have problems, then try to follow the tutorial again

Step 3: ALSA/Pulseaudio, Xorg and more.

You can see that your machine that booted with OpenRC does not work exactly the same as your systemd. That's because many services are missing.

If you want to use ALSA (Advanced Linux Sound Architecture), build and install the alsa-utils-openrc package. It will pull some more packages so I suggest you to put them in some place in case you will need them later (you'll probably do).

$ cower -d alsa-utils-openrc
$ cd openrc-desktop
$ makepkg
$ sudo pacman -U ./alsa-utils-openrc*.pkg.tar.xz

Enable it on boot up and start it:

# rc-update add alsasound boot
# rc-service alsasound start

As I suggested before, make a new directory and put all the other packages in it:

$ mkdir ~/OpenRC
$ mv ./*.pkg.tar.xz ~/OpenRC

If you want to use Pulseaudio (another evil thing made by Poettring! or maybe not that evil at all... you know, it does not take over PID 1... yet ;)) then grab the pulseaudio-openrc package which I happily maintain on the AUR until artoo adds it to one of the groups:

$ cower -d pulseaudio-openrc
$ cd pulseaudio-openrc
$ makepkg
$ sudo pacman -U ./pulseaudio-openrc*.pkg.tar.xz

For Pulseaudio and many other programs to work properly, you will also need ConsoleKit. To build and install consolekit and consolekit-openrc:

$ cower -d consolekit
$ cd consolekit
$ makepkg
$ sudo pacman -U ./consolekit*.pkg.tar.xz
$ cd ..
$ cower -d consolekit-openrc
$ cd openrc-desktop
$ makepkg
$ sudo pacman -U ./consolekit-openrc*.pkg.tar.xz

If you want to find more OpenRC services in the AUR, search it for packages containing -openrc:

$ cower -s -- -openrc

Please also note that you can use services from Gentoo too. Artoo's openrc services belong to specific groups. When you build one of them, you build the whole group. For example, when building Consolekit, you will get much more services from the openrc-desktop group. You can either remove the rest or copy them to a special directory I told you to make before so that in case you need to install them, you can just do pacman -U in that directory. I'd suggest the second option.

Other packages you might be interested on:

  • displaymanager-openrc [Xorg display manager]
  • syslog-ng-openrc [Logging]
  • sane-openrc [Scanning]
  • cups-openrc [Printing]

That's the end of this short part, now time for the real part where you will get systemd out of your system for good (or maybe not?).

Step 4: Where things happen and pacman -Qi systemd libsystemd returns "package not found"

This is the last step. Here you will remove systemd and libsystemd, replacing libsystemd with a stripped down version without udev libs and eudev instead of udev. Time to start. Expect things to break if you don't follow the instructions tightly.

Get eudev and eudev-systemdcompat from AUR:

$ cower -d eudev eudev-systemdcompat

Change directory to eudev and build it:

$ cd eudev
$ makepkg

Now comes the part where you have to be aware. Do not let your computer turn off no matter ANYTHING. Turning your computer off after doing the commands you will soon see will leave your system almost unusable and very hard to fix. You have to remove systemd and libsystemd IGNORING DEPENDENCIES. If you're using a laptop, confirm that it's plugged into a power source. If you're using a stationary computer, confirm there's no expected downtime. After you're sure you'll be safe, execute this:

# pacman -Rdd systemd libsystemd

Confirm the removal. Now, after this, install eudev first:

# pacman -U ./eudev*.pkg.tar.xz

Then change directory to ../eudev-systemdcompat. Open the PKGBUILD file and replace the line containing

_spkgrel=8

with

_spkgrel=1

and

pkgver=217

with

pkgver=218

and

pkgrel=3

with

pkgrel=1

After this, replace two lines starting with "sha256sums" with this:

sha256sums=('SKIP')

Save the file and then build and install it:

$ makepkg
$ sudo pacman -U ./eudev-systemdcompat*.pkg.tar.xz

Before rebooting grab the eudev-openrc package containing the eudev service for OpenRC, build it and install it:

$ cower -d eudev-openrc
$ cd openrc-base
$ makepkg
$ sudo pacman -U ./eudev-openrc*.pkg.tar.xz

Optionally copy all *.pkg.tar.xz files to ~/OpenRC or whatever directory you wish. The eudev service should be enabled automatically. After the installation reboot your computer:

# reboot

Now you should be presented with the exact boot you have seen in step 2. Some errors about network connection may appear. When you get to log into the system, execute:

$ pacman -Qi systemd libsystemd

Look ma! No systemd! https://cdn.mediacru.sh/_UIoZgiglH9E.png

One problem though. As I mentioned before, you don't have internet connection. Why is that?

Well, systemd's udev renames the interface names from wlanX to wlpXsX, ethX to enpXsX etc. To fix your network connection, execute:

$ ip link list

To find the current names for the interfaces. Find the correct one (wlanX for wireless, ethX for wired). Remember it and then execute those commands:

# sed -i 's/OLDDEVICE/DEVICE/g' /etc/conf.d/net
# mv /etc/init.d/net.OLDDEVICE /etc/init.d/net.DEVICE

Replace OLDDEVICE with the old name of the interface (wlpXsX or enpXsX) and DEVICE with the device name you have found doing ip link list before (wlanX or ethX).

Now disable the old service and enable the new one:

# rc-update del net.OLDDEVICE
# rc-update add net.DEVICE default

Replace OLDDEVICE and DEVICE like before. Start the service:

# rc-service net.DEVICE start

If you can now successfully connect to the internet, then congratulations! You have replaced systemd with OpenRC and eudev.

This tutorial is published under the CC0 license. More on the Creative Commons website

I hope this helped someone! Please note that this tutorial may not be accurate. Please report any grammar mistakes or command mistakes to Zatherz, the author of this post (or write a comment below).

User Comments

Ah, you seem to have added a lot of info :)

Instead of the AUR, the method I use is to simply build from artoo's git repo, add all the packages to a local repo, and install from that.

Alternative way to install OpenRC and eudev on Arch

Aaditya (talk) 15:25, 2 December 2014 (UTC)

Troubleshooting OpenRC

Polkit: Not authorized to perform operation

If you get this problem, make sure a consolekit session is running:

ck-list-sessions

If the output is nothing, make sure to launch your WM/DE with ck-launch-session (and with dbus-launch):

ck-launch-session dbus-launch DE/WM

Replace DE/WM with the application that starts your DE/WM (for example startlxqt or openbox),