From ArchWiki
Revision as of 20:25, 1 December 2014 by Zatherz (talk | contribs)
Jump to navigation Jump to search

This was originally a forum post that got deleted, I'll soon convert this to wiki markup

For all your 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 ;)

[b]Step 1.[/b] 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.

[b]Step 2.[/b] 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.

So, let's start. Grab "openrc-core" from the AUR, build and install it (in this example I'll use cower to download the package): [code] cower -d openrc-core cd openrc-core makepkg sudo pacman -U ./openrc-core*.pkg.tar.xz [/code]

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 [url=]Gentoo Handbook[/url] 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: [code] ip link list [/code]

[i]Configuring wired internet connection[/i] On your system with systemd's udev, wireless interfaces will most probably show up as "wlpXsX" and wired - "enpXsX". Find the correct one and execute: [code] cd /etc/init.d ln -s net.lo net.DEVICE [/code] Of course replace "DEVICE" with the name of your wired interface, for example "enp1s7".

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: [code]

  1. For DHCP


  1. For static IP using CIDR notation

config_DEVICE="" routes_DEVICE="default via" dns_servers_DEVICE=""

  1. For static IP using netmask notation

config_DEVICE=" netmask" routes_DEVICE="default via" dns_servers_DEVICE="" [/code] 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.

[i]Configuring wireless network[/i] 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: [code]

  1. Prefer wpa_supplicant over wireless-tools


  1. It's important that we tell wpa_supplicant which driver we should
  2. be using as it's not very good at guessing yet

wpa_supplicant_DEVICE="-Dnl80211" [/code] Substitute DEVICE with the interface name. I choose 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.

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. For the purpose of this tutorial I will name the file "wireless.conf". You can call it whatever you want, just remember to not forget the name or you will have to check it again (and waste 2ms of your precious life ;)). Open the file and fill it with this data: [code] ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 ap_scan=1 network={


} [/code] 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 [url=]Gentoo Handbook[/url] 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: [code] rc-update add net.DEVICE default [/code] Substitude 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 [b]completely[/b] sure you're OK, then it's time to reboot. [code] reboot [/code] On the next boot you should see a friendly message: [code] OpenRC <version> is starting Arch Linux [/code] 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: [code] touch /etc/sysctl.conf [/code] It will create an empty /etc/sysctl.conf which should solve the aforementioned errors. Now is time to check the internet connection.

As your internet connection should autostart on boot, just ping some site you know is online: [code] ping [/code] If ping responds with "unknown host", then you either did not properly configure your network or you just didn't enable it before. Try starting it: [code] rc-service net.DEVICE start [/code] 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: [code] ping [/code] 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 start with 192.168, then enable the service so that it will start on boot: [code] rc-update add net.DEVICE default [/code]

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.

[b]Step 3.[/b] 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). [code] cower -d alsa-utils-openrc cd openrc-desktop makepkg sudo pacman -U ./alsa-utils-openrc*.pkg.tar.xz [/code]

Enable it on boot up and start it: [code] rc-update add alsasound boot rc-service alsasound start [/code]

As I suggested before, make a new directory and put all the other packages in it: [code] mkdir ~/OpenRC mv ./*.pkg.tar.xz ~/OpenRC [/code]

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: [code] cower -d pulseaudio-openrc cd pulseaudio-openrc makepkg sudo pacman -U ./pulseaudio-openrc*.pkg.tar.xz [/code]

For Pulseaudio to work properly, you will also need consolekit2. To build and install it: [code] cower -d consolekit-openrc cd openrc-desktop makepkg sudo pacman -U ./consolekit-openrc*.pkg.tar.xz [/code]

If you want to find more OpenRC services in the AUR, search the AUR for packages containing "-openrc": [code] cower -s -- -openrc [/code]

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 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 services 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?).

[b]Step 4.[/b] Where things happen and pacman -Qi systemd 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: [code] cower -d eudev eudev-systemdcompat [/code]

Change directory to eudev: [code] cd eudev [/code]

Open the PKGBUILD file and remove the line containing "'libsystemd'" in the "provides" array. Save it and build: [code] makepkg [/code]

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 [b]IGNORING DEPENDENCIES[/b]. If you're using a laptop, confirm that it's plugged in to 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: [code] pacman -Rdd systemd libsystemd [/code] Confirm the removal. Now after this, install eudev first: [code] sudo pacman -U ./eudev*.pkg.tar.xz [/code]

Then change directory one lower and then proceed to eudev-systemdcompat. Open the PKGBUILD file and replace the line containing [code] _spkgrel=7 [/code] with [code] _spkgrel=8 [/code]

After this, replace two lines starting with "sha256sums" with this: [code] sha256sums=('SKIP') [/code]

Save the file and then build and install it: [code] makepkg sudo pacman -U ./eudev-systemdcompat*.pkg.tar.xz [/code]

Before rebooting grab the eudev-openrc package containing the eudev service for OpenRC, build it and install it: [code] cower -d eudev-openrc cd openrc-base makepkg sudo pacman -U ./eudev-openrc*.pkg.tar.xz [/code]

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: [code] reboot [/code]

Now you should be presented with the exact boot you have seen in step 2. When you get to log into the system, execute: [code] pacman -Qi systemd libsystemd [/code] Look ma! No systemd! [img][/img] 20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC) This tutorial is published under the CC0 license. More on the [url=]Creative Commons website[/url]. I hope this helped someone! Please note that this tutorial may not be accurate. Please report any grammar mistakes or command mistakes to @Zath, the author of this post.