Difference between revisions of "User:Zatherz"

From ArchWiki
Jump to navigation Jump to search
Line 22: Line 22:
 
Better don't reboot now if you don't want to have no internet connection.
 
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.
 
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=http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=1]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.
+
The [http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=1 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:
+
To make OpenRC know about your network interface, be it wired or wireless, you first have to symlink {{ic|/etc/init.d/net.<INTERFACE DEVICE>}} to {{ic|/etc/init.d/net.lo}}. You can find the name of the device by issuing:
 
<code>
 
<code>
 
ip link list
 
ip link list
Line 252: Line 252:
 
https://cdn.mediacru.sh/_UIoZgiglH9E.png
 
https://cdn.mediacru.sh/_UIoZgiglH9E.png
 
20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC)20:20, 1 December 2014 (UTC)
 
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 [http://creativecommons.org/publicdomain/zero/1.0/legalcode|Creative Commons website]
+
This tutorial is published under the CC0 license. More on the [http://creativecommons.org/publicdomain/zero/1.0/legalcode 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 @Zath, the author of this post.
 
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.

Revision as of 12:47, 2 December 2014

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 ;)

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.

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):

$ 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

Configuring wired internet connection 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: cd /etc/init.d ln -s net.lo net.DEVICE 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:

  1. For DHCP

config_DEVICE="dhcp"

  1. 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"

  1. 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:

  1. Prefer wpa_supplicant over wireless-tools

modules="wpa_supplicant"

  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" 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: 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 [url=http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4&chap=4]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: rc-update add net.DEVICE default 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 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 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 you 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 start with 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 to work properly, you will also need consolekit2. To build and install it: 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 the AUR 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 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?).

Step 4. 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: cower -d eudev eudev-systemdcompat

Change directory to eudev: cd eudev

Open the PKGBUILD file and remove the line containing "'libsystemd'" in the "provides" array. Save it and build: 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 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: pacman -Rdd systemd libsystemd Confirm the removal. Now after this, install eudev first: sudo pacman -U ./eudev*.pkg.tar.xz

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

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. When you get to log into the system, execute: pacman -Qi systemd libsystemd Look ma! No systemd! https://cdn.mediacru.sh/_UIoZgiglH9E.png 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 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 @Zath, the author of this post.