Arch Linux Setup

Updated: 16 minute read

Introduction

A while back I decided to install Arch Linux [1] on my laptop. I had several reasons for that, which I don’t want to discuss here. This post is supposed to document the steps I took to get Arch on my machine and set it up to make it work, look, and feel like I want it to. Since the whole setup is not done yet, and I haven’t written everything down yet (so far there is just a description of the basic installation), this post will certainly be updated in the future, and might become exceptionally long. I also plan on updating this post, when I change something on my setup. This post mainly serves as a resource for myself, in case I ever look for something or try to remember why I did something or how I did it. A lot of this can be found somewhere online of course, but I want to have one central resource that documents everything. Links will be given to the external resources I used. In case anyone else finds this post helpful, I’d be happy that I could help. In case anyone has any better solution for certain parts of my setup, I’d be happy to hear from you.

Basic Installation

First of all, I had to get Arch on my laptop. While I mainly followed the instruction in the Installation guide [2] on the ArchWiki [3] and a youtube video [4] by Luke Smith, I still want to briefly summarize the necessary steps I took.

  • During the installation my laptop was connected to the internet via a Ethernet connection. After booting Arch from the USB drive, that I had put the iso-image on, I made sure my laptop was connected to the internet by pinging archlinux.org:
ping archlinux.org

Update (2020-12-26): I installed Arch on a second laptop. Unfortunatelly the ehternet jack on this laptop sucks and didn’t allow for a stable internet connection. Therefore I had to connect to a wlan. I took quite some time to figure out, how to do that. I found the solution in GAD3R’s answer to the Question How to connect to wifi from command line? [5]:

wpa_supplicant \
    -B \
    -i wlan0 \
    -c <(wpa_passphrase "Your_SSID" Your_passphrase) \
    && dhclient wlan0

This worked while beening in the Arch environment, that I was in after booting Arch from the USB drive. After the base system had been installed and I had used arch-chroot to get into the newly installed system (s. below), I had to use:

nmcli d wifi connect Your_SSID password Your_Psswd_here

to connect to the same wlan.

  • After that I modified the keyboard layout with:
loadkeys de-latin1-nodeadkeys
  • and made sure the time was correct:
timedatectl set-ntp true
timedatectl status
  • Afterwards I partitioned my hard drive using cfdisk instead of fdisk (as suggested in the Arch Wiki Installation Guide). I set up four partitions:
Partition Size Purpose/Mount Point
1 200M /boot
2 10G [SWAP]
3 30G /
4 rest /home

Note: Even though 200M should normally be enough, today I would make the first partition a little bigger. There was a time when I had multiple linux kernels on my machine, and wanted to add yet another one, but could not because I ran out of space on the /boot partition. I don’t recall how many kernels fit though.

Note: My bios is configured to use BIOS and not UEFI to boot. Therefore the disk has to be set up with a MBR (DOS) layout and not a GPT layout. On my second laptop it was set up with a GPT layout, which I didn’t realize, and after the installation I was not able to boot the system. So I had to do it again. Somehow I didn’t see an option in cfdisk to set the layout. I didn’t bother to search for it for a long time, so it might be there, but I don’t know. Therefore I did use fdisk to partition the disk in my second laptop.

Note (2023-08-11): I set up a new laptop today that uses UEFI to boot. Therefore I had to set the partition type of the first partition to “EFI system partition”. In the following I will add more notes, to highlight the differences that this caused in the installation process.

  • After that file systems had to be written onto the partitions and the swap partition had to be set up:
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda4
mkswap /dev/sda2
swapon /dev/sda2

Note (2023-08-11): For UEFI the first partition had to have a FAT filesystem. This was created using the following command (<efi_system_partition>) had to be replaced with the actual partition which in today was not “sda1” but a nvme* device.

mkfs.fat -F 32 /dev/<efi_system_partition>
  • After that was done, the partitions could be mounted:
mount /dev/sda3 /mnt
mkdir /mnt/boot
mkdir /mnt/home
mount /dev/sda4 /mnt/home
mount /dev/sda1 /mnt/boot
  • The next step was to chose some geographically close mirrors in /etc/pacman.d/mirrorlist. I did that with vim, which was on the iso-image.

  • It was finally time to actually install Arch:

pacstrap /mnt base base-devel man-db man-pages texinfo linux linux-firmware
  • Once this was done I setup the fstab file:
genfstab -U /mnt >> /mnt/etc/fstab
  • At this point it’s possible to use arch-chroot, to chroot into the system:
arch-chroot /mnt

Before rebooting the system I went ahead and installed some software and made some initial configurations/adjustments:

  • Luke Smith recommended to install a network manager:
pacman -S networkmanager
systemctl enable NetworkManager
  • install bootloader:
pacman -S grub
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Note (2023-08-11): To install grub for the UEFI system, the commands looked a little different. The first one was used to determine which target I had to chose for grub-install. It returned 64.

cat /sys/firmware/efi/fw_platform_size
pacman -S grub
pacman -S efibootmgr
grub-install --target=x86_64-efi --efi-directory /boot/ --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
  • Set a password for root:
passwd

Note (2023-08-11): To set up the rest, I used some Ansible playbooks and roles, which might be a topic for another post. In order to to that, I just installed python and ssh (see the following command), configured sshd to allow root login with a password, enabled sshd, and set up my user andreas with a password (see further down). I skipped setting up groups, since this is also done with Ansible. And the possibility to connect to the new laptop via ssh as root with a password was disabled by an Ansible role, but I had to be able to login at least once, because I did the setup from another machine.

pacman -S python openssh
  • Adjust and generate the localization:
vim /etc/local.gen
locale-gen
  • Set the system language to English, but the keyboard layout to German:
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=de-latin1-nodeadkeys" > /etc/vconsole.conf
  • Set the right time zone. First look for the right one in /usr/share/zoneinfo, set it, and set the hardware clock:
ls /usr/share/zoneinfo/
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
  • Set the computer/host name in /etc/hostname
echo "[HOSTNAME]" > etc/hostname
  • Add matching entries to etc/hosts, by writing the following lines to it:
127.0.0.1    localhost
::1          localhost
127.0.1.1    [HOSTNAME].localdomain [HOSTNAME]
  • This pretty much completes the basic installation. Now you can exit out of the chroot environment, unmount all partitions, and reboot the system:
exit
umount -R /mnt
reboot
  • After the system rebooted, I logged in as root and set up a new user account for myself, so I don’t have to be root all the time I use my laptop:
useradd -m andreas
passwd andreas
usermod -aG wheel,audio,video,optical,storage andreas
groups andreas
  • In order to be able to run commands as root (sudo) I added myself to the ‘wheel’ group (as just seen) and than uncommented the following line in the file /etc/sudoers:
%wheel ALL=(ALL) ALL

Desktop Environment/Window Manager

Even though, I like working in a terminal and do it a lot, I did want to have some sort of graphical user interface on my laptop.

Video Driver Installation

First of all I had to install a video driver. Well, I guess I didn’t actually have to do that, because I think there is some default driver in Arch, but I did it anyways. In order to do that, I had to figure out what kind of graphics card was build into my laptop. I used the following command to do that:

lspci -v | grep -A1 -e VGA -e 3D

And because of the output of that command, I installed the xf86-video-ati driver:

sudo pacman -S xf86-video-ati

Note: Today (2020-11-20) I deinstalled xf86-video-ati and installed xf86-video-amdgpu instead. I had the problem that in qtile I had screen tearing in firefox. For ages I couldn’t figure out why until I finally found the solution. Changed the driver (the new one seems to be better for my installed AMD RYZEN 5, and add an additional config file (/etc/X11/xorg.conf.d/20-amdgpu.conf) with the following content:

Section "Device"
     Identifier "AMD"
     Driver "amdgpu"
     Option "TearFree" "true"
  EndSection

By the way: To figure out which driver X actually used, you can look into X’s log file, which on my system is located in ~/.local/share/xorg. When I had the xf86-video-ati driver installed, multiple drivers were loaded, but all of them but one got unloaded later, which I didn’t realize of a while. With the new driver only one gets loaded. Another way to check which driver is used is to go to /usr/lib/xorg/modules/drivers. This is where the drivers are installed. Then run the command:

lsof +D .

It tells you which files are open at the moment, this should reveal which driver is being used.

X11 Installation

After the driver installation, I just installed X11 (xorg) and xorg-xinit by running:

sudo pacman -S xorg xorg-xinit

The latter package is needed to be able to start the X-server with the command startx. To run certain commands when the X-server starts using the startx command, you can use an xinitrc file. The current state of my xinitrc file can be found here.

More information about installing X11 (and the graphics driver) can be found in the ArchWiki [6]

KDE Plasma Installation

Even though I planned on using just a window manager and not a full Desktop Environment, I did install a Desktop Environment, because that’s what I was used to from previous Linux installations I used and it allowed me to be up and running quick. I figured installing and configuring a window manger the way I wanted it to look and feel, would take some time (and I was right). Because I had used KDE a lot prior to installing Arch, I decided to go with KDE (Plasma) [7] again.

To install it, I just installed the plasma-meta package:

pacman -S plasma-meta

Since I didn’t want a login manager or anything like that, I have to start the X-server and KDE Plasma with it manually after logging it. This is done with the command:

startx

In order for it to work an ‘.xinitrc’ file is needed. I don’t remember where I got the original file that I used as a starting point from, but here you can find my current version of that file. At the beginning I just added the following line to the .xinitrc file:

exec /urs/bin/startplasma-x11

Qtile installation

As mentioned earlier, I wanted to use a plain window manager for my Arch installation. Therefore I looked into various option before I decided on which one I wanted to install. Derek Taylor’s “A Comprehensive Guide To Tiling Window Mangers” [8] was very helpful here. First I thought about installing xmonad, because I seemed to have the features I was looking for. I especially liked the way it handles workspaces. But since I don’t know any Heskell, I decided to install Qtile [9] instead. I liked, that according to Derek’s guide Qtile is pretty much a clone of xmonad, but is written and configured in python, which I’m way more familiar with than with Heskell.

All that was needed to install it, was:

sudo pacman -S qtile

Qtile comes with a default configuration. Even though the default configuration works fine I guess, I wanted to adjust it to my needs. This took quite a bit longer than installing it, and I’m still not done with it. You can see the current state of my configuration here.

Display Locker

I guess with a full desktop environment you would get some sort of display locker with it, but I needed anthoer solution, since Qtile doesn’t come with a screen locker. My first solution was the XScreenSaver [10]. But while it was running, the fan of my laptop started to turn on a lot, even though no program ran that would have required a lot of cpu resources. It seemed as if the XScreenSaver just needed to much computing power for nothing I needed, because actually all the moving screen saver that were displayed, while the display was locked, kind of annoyed me anyways. Therefore I searched for another solution and found slock [11]. I downloaded the source code patched it a little bit and than installed it. So far I’m pretty happy with it. My build of slock can be found here.

In order to lock the screen when I send my computer into sleep mode (so no one can just use it after it wakes back up), or to lock the screen after a certain time of inactivity, I installed the package xss-lock. To start it every time Qtile starts, I put the following line in an autostart script that is run after Qtile has been started completely:

xss-lock -- slock &

I never changed the default settings for the power saving functionality of my laptop, because I’m content with the default behaviour. And xss-lock automatically takes care of locking the screen when power saving kicks in and turns off the monitor. Very nice!

Application Launcher

While I was running KDE (Plasma) [7] as my desktop environment, I was a big fan of the Krunner to launch applications. Now for my Qtile installation I needed to find something to replace the Krunner with. On my search for an alternative I came across dmenu [12]. I downloaded the source code and patched it a little bit, before installing it. My current build of dmenu can be found here. As with slock, I’m also pretty happy with dmenu so far.

Keyboard Configuration

Essentially I needed two different keyboard configuration. Not because I use two different keyboards (keyboard layouts or so), but because the keyboard settings are apparently configured separately for Xorg and for the virtual console (when Xorg is not running).

Since I don’t use the pure virtual console that much, I decided to leave this configuration simple. The keyboard layout is configured via the file vconsole.conf (see section Basic Installation). While it would be possible to configure additional things (like a keymap, or adjusting the typematic delay and rate), I didn’t really do much here. For more information about configuring the keyboard for the virtual console look into the ArchWiki [13]. One thing I did change was turning on num lock on startup. I did this by adding the following line to my .bash_profile file:

setleds -D +num

Information about how to configure the keyboard in Xorg can also be found in the ArchWiki [14]. For my configuration I wrote a file called 00-keyboard.conf, and added a link to it in /etc/X11/xorg.conf.d. The current version of that file can be found here. Additionally I installed the package numlockx and added the following line to my xinitrc file:

numlockx on

This turns the num lock on, when X is started. This had to be done even though the num lock is actually activated in .bash_profile, but for some reason X doesn’t care about it and you end up with the indication led (for the num lock) being on, but the number block still has the alternative key function, which is pretty annoying.

In order to bind some special keys of the keyboard to certain actions, I installed the package xbindkeys. Information about it can be found in the ArchWiki [15]. So far I only use it to configure the volume control keys of the keyboard, and to adjust the brightness of my laptop monitor, but I might take care of more keys in the future. The keys that you want to bind with xbindkeys are defined in a xbindkeysrc file. The current version of my xbindkeysrc file can be found here. In order to actually run xbindkeys I added the following line to my xinitrc file:

xbindkeys -f "$XDG_CONFIG_HOME"/xbindkeys/xbindkeysrc

I did have some trubble to get the brightness keys to work. For some reason I could not use just XF86MonBrightnessUp and XF86MonBrightnessDown in my xbindkeysrc file, but had to replace it with “Mod2 + XF86MonBrightnessUp” and “Mod2 + XF86MonBrightnessDown”. I don’t know why, but that’s how it is.

It is executed before my window manager is started.

Network Configuration

To manage my network connections I installed networkmanager and enabled it, so the starts automatically at the startup of my computer. Additionally I installed the nm-connection-editor as a graphical user interface to edit my connections and the network-manager-applet (nm-applet) for the system tray. Since I use qtile as my window manager, I added nm-applet to the list of applications that is autostarted when qtile starts. For vpn support the networkmanager-openvpn package was installed.

Somehow I still have the problem, that at startup the wired connection to my router is not established automatically. I don’t know why. That is something, I still have to find you.

nm-applet

After the installation of nm-applet and starting it automatically with qtile, I realized that it get unresponsive at times. On the ArchWiki page for the NetworkManager [16] I found the reason for why that is. Apparently a Desktop notification server was missing. Therefore I installed the notification-daemon and also started it in the autostart script of qtile. The option to start the notification daemon with D-Bus as suggested on the ArchWiki page for Desktop Notifications [17] somehow didn’t work for me. I didn’t bother to figure out way. Now the nm-applet works fine. I don’t quite like the look of the notifications, but for now it’s ok. I might look into it sometime in the future.

Passwords

Since I didn’t want the passwords for the networks I connect to being stored as plain text on my machine, I installed gnome-keyring. To allow applications to use my keyrings, I also installed libsecret, and as a gui to manage my keyrings, I installed seahorse.

To automatically start the gnome-keyring-daemon at login, I added the following line, at the end of the auth section of /etc/pam.d/login:

auth optinal pam_gnome_keyring.so

And the following line at the end of the session section of the same file:

session optional pam_gnome_keyring.so auto_start

After the next login, there was a new keyring called Login in the list of my keyrings (seahorse). I set this keyring to be the default keyring. From than on nm-connections-editor started to save passwords for networds in that keyring, which is automatically unlocked, when I log in into my computer.



Take care,
Andreas


References

  1. J. Vinet and A. Griffin, “Arch Linux.” [Online]. Available at: https://archlinux.org/. [Accessed: 28-Aug-2020].
  2. ArchWiki, “Installation guide,” 28-Sep-2020. [Online]. Available at: https://wiki.archlinux.org/title/installation_guide. [Accessed: 01-Nov-2020].
  3. ArchWiki, “ArchWiki - Main Page.” [Online]. Available at: https://wiki.archlinux.org/. [Accessed: 01-Nov-2020].
  4. L. Smith, “Full Arch Linux Install (SAVAGE Edition!),” 18-Mar-2018. [Online]. Available at: https://www.youtube.com/watch?v=4PBqpX0_UOc. [Accessed: 01-Nov-2020].
  5. GAD3R, “How to connect to wifi from command line?,” 17-May-2016. [Online]. Available at: https://unix.stackexchange.com/questions/283722/how-to-connect-to-wifi-from-command-line. [Accessed: 25-Dec-2020].
  6. ArchWiki, “Xorg.” [Online]. Available at: https://wiki.archlinux.org/title/xorg. [Accessed: 06-Nov-2020].
  7. KDE.org, “KED Community Home.” [Online]. Available at: https://kde.org/. [Accessed: 28-Aug-2020].
  8. D. Taylor, “A Comprehensive Guide To Tiling Window Managers,” 22-Sep-2019. [Online]. Available at: https://www.youtube.com/watch?v=Obzf9ppODJU. [Accessed: 06-Nov-2020].
  9. Qtile, “Qtile – A hackable tiling window manager written in Python.” [Online]. Available at: https://qtile.org/. [Accessed: 07-Feb-2024].
  10. J. Zawinski, “XScreenSaver.” [Online]. Available at: https://www.jwz.org/xscreensaver/. [Accessed: 13-Nov-2020].
  11. suckless.org, “slock.” [Online]. Available at: https://tools.suckless.org/slock/. [Accessed: 13-Nov-2020].
  12. suckless.org, “dmenu.” [Online]. Available at: https://tools.suckless.org/dmenu/. [Accessed: 13-Nov-2020].
  13. ArchWiki, “Linux console/Keyboard configuration,” 14-Nov-2020. [Online]. Available at: https://wiki.archlinux.org/title/Linux_console/Keyboard_configuration. [Accessed: 22-Nov-2020].
  14. ArchWiki, “Xorg/Keyboard configuration,” 07-Feb-2024. [Online]. Available at: https://wiki.archlinux.org/indexi.php/Xorg/Keyboard_configuration. [Accessed: 22-Nov-2020].
  15. ArchWiki, “Xbindkeys,” 07-Feb-2024. [Online]. Available at: https://wiki.archlinux.org/title/Xbindkeys. [Accessed: 22-Nov-2020].
  16. ArchWiki, “NetworkManager,” 13-Dec-2020. [Online]. Available at: https://wiki.archlinux.org/title/NetworkManager. [Accessed: 25-Dec-2020].
  17. ArchWiki, “Desktop Notifications,” 07-Feb-2024. [Online]. Available at: https://wiki.archlinux.org/titel/Desktop_notifications. [Accessed: 25-Dec-2020].

Updated:

Leave a comment