Systemd might be monolithic but since you already have it installed why not use it?
As many Linux users know there is conflict when using systemd as the init system, many argue that it doesn’t follow the Unix philosophy or that it is bloated. But those users also tend to bloat their Linux install by installing redundant packages like NetworkManager or grub. Systemd already has this functionality, in this article I will show you how to use them keeping our systems lean.
bootctl
Let’s start with booting, don’t get me wrong grub has its place but there are limited scenarios you will be inclined to use it if you are not sure you can check this arch wiki article.
If you are using UEFI like in most modern systems using bootcl (systemd boot) is fine.
It goes without saying but of course disable secure boot.
bootclt install
This command will place all the necessary files in the boot directory but hold your horses it wont boot yet. To boot you need to have an entry and loader. Entry basically is the configuration for the boot menu (in this guide I will assume you only have arch installed). And the loader points to the initramfs and linux bootable image to boot your install. The first file to modify is located in “/boot/loader/loader.conf”. For a fast no delay boot I use the following configuration, default point to the entry arch.conf and timeout 0 means there will be no display to select to boot arch and arch.conf loads your arch install automatically (the name is arbitrary to call it whatever but it must match your entry.
default arch.conf
timeout 0
Now lets make the entry, it will be located in “/boot/loader/entries/arch.conf”. The title is what will appear in the boot menu but we won’t see it. Now the next lines load the initramfs and linux image to boot your Arch install. Lastly the options point to your root partition you can just use the device for instance /dev/sda2, but it’s not recommended you should use your UUID that is located in /etc/fstab and it’s a long string, making this entry look like this root=UUID=12345…
title arch
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=<your root partition> rw quiet
To add your UUID easily you can use the following command, the second command will add the UUID with all the options.
awk '$2 == "/" && $1 ~ /^UUID=/ {print $1}' /etc/fstab >> /boot/loader/entries/arch.conf
awk '$2 == "/" && $1 ~ /^UUID=/ {print "options root="$1 " rw quiet"}' /etc/fstab >> /boot/loader/entries/arch.conf
Now you have a bootable system, congratulations!, if you want further reading check the wiki article.
Systemd-networkd
As you probably have guessed it’s already installed as part of systemd. To configure and use you can configure each interface which is recommended or set a global config. To do DNS resolving we will use systemd-resolved and will enable it in later steps. Lastly before we start if you are using wireless you will probably want to install iwd to manage wifi connections. Before enabling it run the following command to get the name of the interfaces:
ip a
With that create the config files for your wired and wireless, if you don’t have one of these you can skip the config of that interface. Let’s start with wired connection, create the config file in the following location “/etc/systemd/network/20-wired.network” and add the following for DCHP. For a static IP remove the DHCP and replace it with Address, Gateway, DNS.
[Match]
Name=<name of the interface>
[Network]
DHCP=yes
Now for wireless connection, create the config file in the following location “/etc/systemd/network/25-wireless.network” and add the following for DCHP. Again for a static IP remove the DHCP and replace it with Address, Gateway, DNS.
[Match]
Name=<name of your wlan interface>
[Network]
DHCP=yes
IgnoreCarrierLoss=3s
Now we can start and enable the systemd service with the following commands.
systemctl enable --now systemd-networkd.service systemd-resolved.service
The final step is to propagate the DNS servers so other apps and compilers can see a valid connection with the following command.
ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
To use iwd to find and connect to wifi you will have to start and enable the service with the command.
systemctl enable --now iwd.service
Iwd will now be used to connect to wifi, to do this you must enter into the iwd command prompt with “iwctl”. Once there to scan and see wifi names to connect you will use the following
station <your wlan interfacename> scan
station <your wlan interfacename> get-networks
station <your wlan interfacename> connect “your SSID”
To exit the iwctl command prompt just type “exit”. With all of that you will have a functioning network setup and will use more of the systemd modules and reducing the bloat on your system. For further reading read the arch wiki article.