ArchLinux SetupGuide - v2023 10 20
ArchLinux SetupGuide - v2023 10 20
v2023-10-20
Table of Contents
0 INTRO............................................................................................................................... 4
0.1 Recommended prerequisites..................................................................................... 4
0.2 Key features – Realization of goals............................................................................4
0.3 Styles & Meaning....................................................................................................... 6
0.4 Notes.......................................................................................................................... 6
1 Pre-boot............................................................................................................................7
1.1 Acquire an installation image......................................................................................7
1.2 Prepare the USB flash installation medium................................................................7
1.3 Set up UEFI................................................................................................................8
1.4 Notes for MS Windows dual booters..........................................................................8
1.5 For Oracle VM VirtualBox: Port Forwarding...............................................................8
2 Pre-installation................................................................................................................ 9
2.1 Boot from USB flash installation medium...................................................................9
2.2 Set the keyboard layout..............................................................................................9
2.3 Verify the EFI-boot mode (64-bit, x86_64).................................................................9
2.4 Connect to the internet...............................................................................................9
2.5 Set temporary root password (for ssh root login).......................................................9
2.6 Connect via ssh (as root)........................................................................................... 9
2.7 Update the system clock..........................................................................................10
2.8 Preparing the disk.....................................................................................................11
2.9 Partition the disk using gdisk – ESP + Root.............................................................14
2.10 Format & Mount the partitions – Btrfs on LUKS + ESP..........................................15
3 Install essential packages............................................................................................ 18
3.1 Basic........................................................................................................................ 18
3.2 Disk management.................................................................................................... 18
3.3 Firmware.................................................................................................................. 18
3.4 Networking............................................................................................................... 18
3.5 Text editor.................................................................................................................18
3.6 Documentation (man & info pages)..........................................................................18
3.7 Pacman tools........................................................................................................... 18
3.8 OPT: Dynamic Kernel Module Support (DKMS).......................................................18
4 System configuration....................................................................................................19
4.1 Generate an fstab file...............................................................................................19
4.2 Chroot...................................................................................................................... 19
4.3 Time......................................................................................................................... 19
4.4 Locale.......................................................................................................................19
4.5 Network.................................................................................................................... 20
4.6 Set root password.................................................................................................... 20
4.7 Allow ssh root login (for next boots).........................................................................20
4.8 Swap (also for hibernation)......................................................................................21
4.9 Mkinitcpio (for UKI)...................................................................................................22
4.10 Kernel command line (for mkinitcpio).....................................................................23
1/91
4.11 Create UEFI boot entries using efibootmgr............................................................25
4.12 Check if everything is working................................................................................25
4.13 Enter crypt-password & Login as root....................................................................25
4.14 For next steps........................................................................................................ 25
5 Secure Boot................................................................................................................... 26
5.1 Install efitools........................................................................................................... 26
5.2 Creating keys in /root/efi-keys/.................................................................................26
5.3 Signing the UKIs (using mkinitcpio post hook).........................................................28
5.4 Putting firmware in "Setup Mode".............................................................................29
5.5 Enrolling keys using sbkeysync................................................................................29
5.6 Completing Secure Boot.......................................................................................... 30
5.7 Verify Secure Boot status.........................................................................................30
6 System configuration (cont.)........................................................................................31
6.1 Locale (cont.): Set locale variables..........................................................................31
6.2 Normal user..............................................................................................................32
6.3 Pacman configuration...............................................................................................33
6.4 Auto update mirrors – reflector.................................................................................33
6.5 Discard unused packages weekly – paccache.........................................................34
6.6 Limit journal size – systemd/Journal........................................................................34
6.7 Improving compile times – Makepkg........................................................................34
6.8 Enable Periodic TRIM (if TRIM is supported)...........................................................35
7 Install Backend & DE.....................................................................................................36
7.1 Graphics driver.........................................................................................................36
7.2 Fonts........................................................................................................................ 38
7.3 Multimedia frameworks............................................................................................ 38
7.4 WM/DE – KDE Plasma + KDE Gear........................................................................40
7.5 Misc.......................................................................................................................... 41
7.6 After installation........................................................................................................41
8 Display Manager – SDDM (for KDE).............................................................................42
8.1 Configuration............................................................................................................42
8.2 Enable SDDM & Reboot...........................................................................................42
8.3 Login as user............................................................................................................42
8.4 Congratulations on reaching this point!....................................................................42
8.5 Change SDDM theme to "Breeze"...........................................................................42
9 Btrfs snapshots............................................................................................................. 43
9.1 Setup snapshots using snapper & snap-pac............................................................43
9.2 Restoring / (subvolume @) to its previous snapshot................................................45
10 Security – Hardening Arch Linux...............................................................................47
10.1 Open interactive shell with root prompt for this chapter.........................................47
10.2 Restrict programs' capabilities – AppArmor............................................................47
10.3 Sandboxing applications – Firejail..........................................................................49
10.4 More Kernel Hardening..........................................................................................51
10.5 Firewall – Firewalld.................................................................................................52
10.6 fwupd (Firmware updater & Verify platform security)..............................................53
10.7 Harden yourself......................................................................................................53
11 User-specific configurations......................................................................................54
11.1 kdesu: Use "doas" instead of "su" (for KDE)..........................................................54
11.2 AUR helper & Pacman wrapper – paru...................................................................54
11.3 Reduce output latency............................................................................................55
11.4 Configuring $PATH (for Zsh, ROCm)......................................................................55
2/91
11.5 PipeWire optimizations...........................................................................................56
12 Hardware specific........................................................................................................59
12.1 Sensors.................................................................................................................. 59
12.2 OPT: Fan speed control..........................................................................................59
12.3 OPT: Stress testing.................................................................................................59
12.4 Printer & Scanner...................................................................................................60
12.5 Fingerprint reader...................................................................................................60
12.6 RGB Control...........................................................................................................61
12.7 Peripherals............................................................................................................. 61
12.8 Desktop-PC (DDR5) – Hardware Recommendations............................................62
13 Software specific.........................................................................................................63
13.1 Copy config files (Here: using sftp)........................................................................63
13.2 Zsh......................................................................................................................... 63
13.3 Install your packages from text files (using zsh).....................................................63
13.4 Firefox.................................................................................................................... 64
13.5 Gamemode (for low latency)..................................................................................68
13.6 Monitoring system performance – MangoHud.......................................................69
13.7 Gaming...................................................................................................................71
13.8 Virtualization...........................................................................................................72
13.9 mpv (media player).................................................................................................78
13.10 OPT: Easy Effects (for EQ & more)......................................................................79
13.11 Rust (using rustup, for devs)................................................................................80
14 Disks & Data................................................................................................................ 81
14.1 Preparing the disk (as root)....................................................................................81
14.2 Setup encrypted internal disk (as root)...................................................................81
14.3 TODO – OPT: Directory structure of your private data...........................................84
14.4 TODO: Create a backup plan.................................................................................85
15 Maintenance.................................................................................................................86
15.1 Removing unused packages..................................................................................86
15.2 Pacnew and Pacsave.............................................................................................86
15.3 Free up disk space.................................................................................................87
16 Troubleshooting.......................................................................................................... 88
16.1 Downgrading packages..........................................................................................88
16.2 Check for errors (also for maintanance).................................................................88
16.3 Useful keyboard shortcuts......................................................................................89
16.4 Pacman: "invalid or corrupted package PGP signature"........................................90
16.5 Audio problems > Restart PipeWire.......................................................................90
16.6 KDE upgrade problems > Clean cache..................................................................90
17 TODOs.......................................................................................................................... 91
17.1 Additions.................................................................................................................91
17.2 Deprecations.......................................................................................................... 91
17.3 Current bugs & misbehaviors.................................................................................91
3/91
0 INTRO
This extensive & modular guide focuses on how to install and set up Arch Linux with the
following goals in mind. The system should:
• be as stable as possible,
• be sufficiently secure (without compromising usability too much),
• have acceptable low latency (for real-time applications, including games),
• be automated as much as possible (also for a small maintenance of the system),
• be well set up for KDE, Gaming, Firefox, mpv, Virt-Manager, your hardware, …
This guide should be very helpful especially – but not only – for Arch beginners.
Many sections (esp. after installation) should be adaptable to other distributions.
4/91
0.2.4 System Hardening
• Restrict programs' capabilities: AppArmor
• Sandboxing applications: Firejail (AA is required)
• Firewall: Firewalld
• Kernel Hardening
5/91
0.3 Styles & Meaning
Style Meaning
BRICK <something you probably want to change>
GRAY <OPT = optional, not always a good option>, <ALT = alternative>,
<not necessary>
DARK RED 2 <ATTENTION>
RED <BAD>, <You can really mess up>, <deletions>
GREEN <OK>, <already good adjustment>, <additions>, <uncomment>
GOLD, BLUE, For highlighting
BOLD
command;
0.4 Notes
• Get the current version of this guide
• Disclaimer: This document is often adapted from the official ArchWiki => General disclaimer
6/91
1 Pre-boot
1.1 Acquire an installation image
https://archlinux.org/download/ > See: HTTP Direct Downloads
7/91
1.3 Set up UEFI
1.3.1 Update UEFI firmware
• Download latest stable UEFI firmware
• Update the UEFI firmware
• OPT: Reset UEFI settings
1.3.2.1 Basic
• Disable Secure Boot. Later we will set that up
• Disable CSM (Compatibility Support Module) for "UEFI only"
• OPT: Disable Fast Boot for full initialization
8/91
2 Pre-installation
2.1 Boot from USB flash installation medium
Note: Press vendor specific key after POST to open the UEFI boot menu.
ALT: Set boot order in UEFI firmware setup utility.
9/91
2.6.3 Connect to (new) IP address
Note: In LAN often 192.168.X.Y, else see here.
Note: You may want to delete the fingerprint(s) from last session in ~/.ssh/known_hosts.
ssh root@<ip -br addr>
10/91
2.8 Preparing the disk
Note: The drive should be connected directly to a SATA/NVMe/… interface. Issuing the Secure
Erase/Format/Sanitize command on a drive via USB or a SAS/RAID card could brick the drive!
11/91
2.8.4 (Secure) Erasure of the drive
https://wiki.archlinux.org/title/Dm-crypt/Drive_preparation
2.8.4.3.2 Change the LBA format with its sector size (Here: NVMe)
nvme format --lbaf=<lbaf> /dev/nvme0n1 (Here: 1)
12/91
2.8.4.5 Prevent cryptographic attacks or file recovery (for dm-crypt)
https://wiki.archlinux.org/title/Dm-crypt/Drive_preparation#dm-
crypt_wipe_on_an_empty_disk_or_partition
Wipe the disk with crypto-grade randomness if the disk contains non-random or unencrypted data.
13/91
2.9 Partition the disk using gdisk – ESP + Root
Modified: Btrfs on LUKS, FDE + TPM2 & Secure Boot
https://wiki.archlinux.org/title/GPT_fdisk
https://wiki.archlinux.org/title/EFI_system_partition#Create_the_partition
Note: Currently, an installed kernel consumes around 100 MiB on the ESP. You can reduce the
size of the ESP to 550 MiB.
gdisk /dev/nvme0n1
>
14/91
2.10 Format & Mount the partitions – Btrfs on LUKS + ESP
https://wiki.archlinux.org/title/Partitioning
https://wiki.archlinux.org/title/Security#Mount_options
https://en.wikipedia.org/wiki/Comparison_of_file_systems
15/91
2.10.2 Preparing btrfs (for snapper & swap)
https://wiki.archlinux.org/title/Btrfs#Subvolumes
https://wiki.archlinux.org/title/Snapper#Suggested_filesystem_layout
16/91
2.10.3 Preparing the EFI system partition (ESP)
https://wiki.archlinux.org/title/EFI_system_partition#Typical_mount_points
Note: The esp will be mounted on /efi (for UKI).
mkfs.fat -F32 /dev/nvme0n1p1;
mount -m -o umask=0077,noexec,nosuid,nodev /dev/nvme0n1p1 /mnt/efi;
17/91
3 Install essential packages
https://wiki.archlinux.org/title/Installation_guide#Install_essential_packages
pacstrap -K /mnt <packages in this chapter>
3.1 Basic
https://wiki.archlinux.org/title/Kernel, Benchmarks 2023-01
Basic: base base-devel linux-firmware
UKI generator: mkinitcpio (Possibly missing firmware)
3.3 Firmware
Microcode (not for VM): amd-ucode or intel-ucode
For some audio devices (≥2020): sof-firmware and/or alsa-ucm-conf
For some audio devices: alsa-firmware
3.4 Networking
Network manager: networkmanager (Wiki)
18/91
4 System configuration
4.1 Generate an fstab file
genfstab -U /mnt >> /mnt/etc/fstab;
4.2 Chroot
https://wiki.archlinux.org/title/Chroot#Using_arch-chroot
arch-chroot /mnt
4.3 Time
https://wiki.archlinux.org/title/System_time
4.4 Locale
https://wiki.archlinux.org/title/Locale
locale-gen
19/91
4.4.2 Set persistent keymap layout (for crypt-password in 1st boot)
https://wiki.archlinux.org/title/Linux_console/Keyboard_configuration
… because localectl set-keymap only works after a reboot.
4.5 Network
https://wiki.archlinux.org/title/Network_configuration
vim /etc/conf.d/wireless-regdom
> Uncomment:
WIRELESS_REGDOM="DE"
20/91
4.8 Swap (also for hibernation)
https://wiki.archlinux.org/title/Swap
https://wiki.archlinux.org/title/Btrfs#Swap_file
https://btrfs.readthedocs.io/en/latest/Swapfile.html
https://man.archlinux.org/man/btrfs.5.en#SWAPFILE_SUPPORT
… to extend the virtual memory beyond the installed physical memory (RAM) or to be able to
hibernate.
21/91
4.9 Mkinitcpio (for UKI)
4.9.1 HOOKS (for systemd init & fsck, dm-crypt & hibernation)
https://wiki.archlinux.org/title/Mkinitcpio#HOOKS
https://wiki.archlinux.org/title/Fsck
Note – If not using dm-crypt: Don't add sd-encrypt or shift keyboard.
vim /etc/mkinitcpio.conf
> HOOKS=(base udev systemd keyboard autodetect modconf kms keyboard keymap
consolefont block sd-vconsole sd-encrypt filesystems fsck)
vim /etc/mkinitcpio.d/linux-zen.preset
> Change:
#default_image="/boot/initramfs-linux-zen.img"
default_uki="/efi/EFI/Linux/archlinux-zen.efi"
default_options="--splash=/usr/share/systemd/bootctl/splash-arch.bmp"
#fallback_image="/boot/initramfs-linux-zen-fallback.img"
fallback_uki="/efi/EFI/Linux/archlinux-zen-fallback.efi"
fallback_options="-S autodetect"
22/91
4.10 Kernel command line (for mkinitcpio)
… with your kernel parameters.
https://wiki.archlinux.org/title/Unified_kernel_image#mkinitcpio
https://wiki.archlinux.org/title/Kernel_parameters
https://docs.kernel.org/admin-guide/kernel-parameters.html
Note: <Output of <command> in vim (normal mode) using :r! <command>>
23/91
4.10.2 performance.conf
vim /etc/cmdline.d/performance.conf
>
• Add: amd_pstate=active
24/91
4.11 Create UEFI boot entries using efibootmgr
https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface#efibootmgr
ALT: https://wiki.archlinux.org/title/Unified_kernel_image#systemd-boot
… to boot directly from UEFI firmware.
pacman -S efibootmgr;
25/91
5 Secure Boot
READ: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/
Secure_Boot#Using_your_own_keys
Note: You may need "Microsoft's UEFI CA certificates" (see below), otherwise your hardware
might be bricked.
26/91
5.2.6 Microsoft's certificates
READ: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface/
Secure_Boot#Microsoft_Windows
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-secure-boot-
key-creation-and-management-guidance (Apparently, the 2023 certs are currently flawed)
Note: Secure Boot sometimes only works in "Windows UEFI mode", so at least Microsoft's UEFI
CA certificates have to be included in the in the UEFI keystore.
cd ..
27/91
5.3 Signing the UKIs (using mkinitcpio post hook)
https://wiki.archlinux.org/title/Unified_kernel_image#Signing_the_UKIs_for_Secure_Boot
pacman -S --needed sbsigntools;
vim /etc/initcpio/post/uki-sbsign
>
#!/usr/bin/env bash
uki="$3"
[[ -n "$uki" ]] || exit 0
keypairs=(/root/efi-keys/db.key /root/efi-keys/db.crt)
chmod +x /etc/initcpio/post/uki-sbsign;
mkinitcpio -P
28/91
5.4 Putting firmware in "Setup Mode"
5.4.1 Reboot into UEFI firmware setup utility
systemctl reboot --firmware-setup OR by hitting [F2] after POST
cp /root/efi-keys/db.auth /etc/secureboot/keys/db/;
cp /root/efi-keys/KEK.auth /etc/secureboot/keys/KEK/;
cp /root/efi-keys/PK.auth /etc/secureboot/keys/PK/;
Microsoft's certificates:
cp /root/efi-keys/add_MS_UEFI_db.auth /etc/secureboot/keys/db/;
cp /root/efi-keys/add_MS_Win_db.auth /etc/secureboot/keys/db/;
5.5.2 Verify the changes sbkeysync will make to the UEFI keystore
sbkeysync --pk --dry-run --verbose
29/91
5.6 Completing Secure Boot
• Reboot to UEFI
• Enable Secure Boot (e.g. enable "Windows UEFI mode")
• Set UEFI administrator password to protect the firmware settings
• Reboot
30/91
6 System configuration (cont.)
6.1 Locale (cont.): Set locale variables
https://wiki.archlinux.org/title/Locale#Variables
Available locales: localectl list-locales;
31/91
6.2 Normal user
https://wiki.archlinux.org/title/Users_and_groups#User_management
passwd myUsername
> myUserPassword
vim /etc/doas.conf
>
permit :wheel
permit persist :wheel
32/91
6.2.5 Allow only users of group wheel "su" access
https://wiki.archlinux.org/title/Su#su_and_wheel
vim /etc/pam.d/su
vim /etc/pam.d/su-l
> Uncomment:
auth required pam_wheel.so use_uid
6.2.6 Realtime
https://wiki.archlinux.org/title/Realtime_process_management
pacman -S realtime-privileges;
usermod -aG realtime myUsername
vim /etc/xdg/reflector/reflector.conf
> Uncomment:
--country Germany
33/91
6.5 Discard unused packages weekly – paccache
https://wiki.archlinux.org/title/Pacman#Cleaning_the_package_cache
systemctl enable paccache.timer;
34/91
6.8 Enable Periodic TRIM (if TRIM is supported)
https://wiki.archlinux.org/title/Btrfs#SSD_TRIM
https://wiki.archlinux.org/title/Solid_state_drive#TRIM
Note: TRIM support is disabled by the device-mapper by default, see (root):
35/91
7 Install Backend & DE
pacman -S <your packages in this chapter>
7.1.2 AMD
https://wiki.archlinux.org/title/AMDGPU
7.1.2.1 Vulkan
vulkan-radeon lib32-vulkan-radeon (ALT: amdvlk lib32-amdvlk)
7.1.2.4.2 OpenCL
rocm-opencl-runtime
36/91
7.1.3 Intel
https://wiki.archlinux.org/title/Intel_graphics
7.1.3.1 Vulkan
vulkan-intel lib32-vulkan-intel
7.1.3.3 OpenCL
intel-compute-runtime (ALT: opencl-rusticl-mesa)
7.1.4 NVIDIA
READ: https://wiki.archlinux.org/title/NVIDIA
+ Wayland fix: https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting
Note: CUDA requires the proprietary NVIDIA kernel module (> no nvidia-open*).
7.1.4.2 OpenCL
opencl-nvidia
7.1.4.3 CUDA
cuda
37/91
7.1.6 Oracle VirtualBox Guest Additions
https://wiki.archlinux.org/title/VirtualBox/Install_Arch_Linux_as_a_guest
virtualbox-guest-utils OR virtualbox-guest-utils-nox (Wayland only)
> systemctl enable vboxservice.service;
7.1.7.1 AMD
xf86-video-amdgpu
7.1.7.2 Intel
xf86-video-intel (not recommended for KDE)
7.1.7.3 Other
lspci | grep -e VGA -e 3D
> Search:
pacman -Ss xf86-video
7.2 Fonts
https://wiki.archlinux.org/title/Fonts
LibreOffice: ttf-liberation
For KDE (full unicode coverage): noto-fonts noto-fonts-cjk noto-fonts-emoji
OPT – HQ, for Firefox, mpv, …: adobe-source-sans-fonts adobe-source-han-sans-otc-fonts
OPT – Monospaced w/ programming ligatures: ttf-fira-code (13 pt) (ALT: ttf-firacode-nerd)
38/91
7.3.3 Gstreamer – Multimedia framework
https://wiki.archlinux.org/title/GStreamer
7.3.3.4 Plugins
gst-libav gst-plugins-good gst-plugins-bad gst-plugins-ugly
39/91
7.4 WM/DE – KDE Plasma + KDE Gear
Comparison of Desktop Environments: https://eylenburg.github.io/de_comparison.htm
7.4.4 Misc.
• File archiver – 7z & RAR: p7zip unrar
• Flatpak: flatpak-kcm
• KDE Connect: kdeconnect sshfs
• On-screen keyboard: maliit-keyboard
• Faster find than find (for kfind): plocate > systemctl enable plocate-updatedb.timer
40/91
7.5 Misc.
https://wiki.archlinux.org/title/Laptop
7.5.3.1 CD
libcdio
KDE: audiocd-kio
7.5.3.2 DVD
libdvdread libdvdcss libdvdnav
7.5.3.3 Blu-ray
READ: https://wiki.archlinux.org/title/Blu-ray#Playback
libbluray libaacs libbdplusAUR
41/91
8 Display Manager – SDDM (for KDE)
https://wiki.archlinux.org/title/SDDM
8.1 Configuration
8.1.1 Rootless Xorg & Wayland
https://wiki.archlinux.org/title/SDDM#Rootless_Xorg
TODO: https://wiki.archlinux.org/title/SDDM#Running_under_Wayland
Note: Currently logging out or switching user is not (well) supported.
mkdir /etc/sddm.conf.d;
vim /etc/sddm.conf.d/rootless-x11.conf
>
[General]
DisplayServer=x11-user
vim /etc/sddm.conf.d/virtualkbd.conf
>
[General]
InputMethod=qtvirtualkeyboard
42/91
9 Btrfs snapshots
9.1 Setup snapshots using snapper & snap-pac
https://wiki.archlinux.org/title/Snapper
9.1.1 Open interactive shell with root prompt for this chapter
doas -s
9.1.2 Installation
pacman -S snapper;
OPT – Check:
btrfs subvolume list /
43/91
9.1.4 Other configurations
9.1.4.1 Lower snapshot limits & Disable timeline snapshots (for snap-pac)
Note: Snap-pac creates pre/post snapshots (with numbers).
vim /etc/snapper/configs/root
>
NUMBER_CLEANUP="yes"
...
NUMBER_LIMIT="20" (Note: For 10 pacman transactions; for number cleanup algorithm)
...
TIMELINE_CREATE="no"
...
TIMELINE_CLEANUP="no"
vim /etc/pacman.d/hooks/95-efibackup.hook
>
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Path
Target = usr/lib/modules/*/vmlinuz
[Action]
Depends = rsync
Description = Backing up /efi ...
When = PostTransaction
Exec = /usr/bin/rsync -a --delete /efi /.efibackup
44/91
9.2 Restoring / (subvolume @) to its previous snapshot
Note: Restore now to check if it works and later if the system is broken.
9.2.1 Disable Secure Boot & Boot into a live Arch Linux environment
9.2.3 Delete the old backup & Backup "broken" root subvolume
Delete the old "broken" backup:
btrfs subvolume delete /mnt/@.broken
Backup:
mv /mnt/@ /mnt/@.broken
9.2.4 Find the snapshot number <num> that you want to recover
grep -r '<date>' /mnt/@snapshots/*/info.xml
> /mnt/@snapshots/<num>/info.xml: <date>yyyy-mm-dd hh:mm:ss</date>
45/91
9.2.10 Fix pacman error: "failed to synchronize all databases"
https://wiki.archlinux.org/title/
Pacman#"Failed_to_init_transaction_(unable_to_lock_database)"_error
doas rm /var/lib/pacman/db.lck
46/91
10 Security – Hardening Arch Linux
READ: https://wiki.archlinux.org/title/Security
GOAL: Creation of a secure and useful system.
10.1 Open interactive shell with root prompt for this chapter
doas -s
10.2.1 Installation
10.2.1.1 Kernel parameters (for UKI)
vim /etc/cmdline.d/security.conf
>
# AppArmor
lsm=landlock,lockdown,yama,integrity,apparmor,bpf
Note: Make sure that apparmor is the first "major" module in the list.
vim /etc/cmdline.d/security.conf
>
# Kernel lockdown
lockdown=integrity
47/91
10.2.3 Reboot
systemctl reboot
10.2.4 Verify
aa-enabled;
aa-status;
48/91
10.3 Sandboxing applications – Firejail
https://wiki.archlinux.org/title/Security#Sandboxing_applications
READ: https://wiki.archlinux.org/title/Firejail
10.3.1 Installation
pacman -S firejail;
[Action]
Description = Configure symlinks in /usr/local/bin based on firecfg.config...
When = PostTransaction
Depends = firejail
Exec = /bin/sh -c 'firecfg >/dev/null 2>&1'
49/91
10.3.7 Creating firejail overrides (if an app is not working properly)
READ: https://github.com/netblue30/firejail/wiki/Creating-overrides
10.3.8 Notes
• The ~/Downloads directory can be considered as a shared directory. So do not store any
important files there.
• You can create you own profiles in ~/.config/firejail/<app>.profile
50/91
10.4 More Kernel Hardening
https://wiki.archlinux.org/title/Security#Kernel_hardening
https://wiki.archlinux.org/title/Sysctl
51/91
10.5 Firewall – Firewalld
READ: https://wiki.archlinux.org/title/Firewalld
Note: default_zone=public
Add service:
firewall-cmd --permanent --zone=home --add-service=kdeconnect;
firewall-cmd --reload
52/91
10.6 fwupd (Firmware updater & Verify platform security)
https://wiki.archlinux.org/title/Fwupd
Devices supported by LVFS: https://fwupd.org/lvfs/devicelist
fwupd
10.6.3 Setup for UEFI upgrade (using own keys & pacman hook)
https://wiki.archlinux.org/title/Fwupd#Using_your_own_keys
vim /etc/pacman.d/hooks/sign-fwupd-secureboot.hook
>
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = usr/lib/fwupd/efi/fwupdx64.efi
[Action]
Description = Signing fwupdx64.efi for SecureBoot...
When = PostTransaction
Exec = /usr/bin/sbsign --key /root/efi-keys/db.key --cert /root/efi-
keys/db.crt /usr/lib/fwupd/efi/fwupdx64.efi
Depends = sbsigntools
53/91
11 User-specific configurations
11.1 kdesu: Use "doas" instead of "su" (for KDE)
https://wiki.archlinux.org/title/Sudo#kdesu
vim ~/.config/kdesurc
>
[super-user-command]
super-user-command=doas
cd ..; rm -r paru/;
vim ~/.config/paru/paru.conf
> Uncomment:
[bin]
Sudo = doas
54/91
11.3 Reduce output latency
Note: Setting these options may cause tearing and short-lived artifacts to appear.
TODO – ALT: Intel Smooth Sync (Intel only).
55/91
11.5 PipeWire optimizations
https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis
https://pipewire.pages.freedesktop.org/wireplumber/
vim ~/.config/pipewire/client.conf.d/resample-quality.conf
vim ~/.config/pipewire/client-rt.conf.d/resample-quality.conf
vim ~/.config/pipewire/pipewire-pulse.conf.d/resample-quality.conf
>
stream.properties = {
resample.quality = 10
}
56/91
11.5.4 Auto change sample rate
https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Config-PipeWire#setting-sample-rates
… to avoid up- & downsampling. 48 kHz should still be the default sample rate.
Note: This may cause minor problems.
57/91
11.5.5 Reduce default latency: Decrease quantum (buffer size)
… if the client does not specify a quantum.
11.5.5.1 Infos
latency = quantum / sampleRate
default_latency = default_quantum / default_sampleRate = 1024 / 48 kHz = 21.3 ms
Note: When the graph is using the 96000 samplerate (default_sampleRate * 2), the quantum
values are scaled (default_quantum * 2 = 2048 ≤ quantum-limit).
Note: In order for the setting to be adopted, you may pause the audio stream for a short time.
Note: When sampleRate = 44100 Hz < default_sampleRate
→ quantum = default_quantum / 2
→ latency ≈ default_latency / 2
So at 32/44100 you should not hear any disturbing noises.
ALT – Set: default.clock.min-quantum = 64 (= default.clock.quantum)
ALSA status:
cat /proc/asound/card*/pcm*p/sub*/hw_params
58/91
12 Hardware specific
12.1 Sensors
https://wiki.archlinux.org/title/Lm_sensors
12.1.1 Setup
Note: Only use default options (by just hitting enter), unless you know exactly what you are doing.
doas sensors-detect
> enter
59/91
12.4 Printer & Scanner
12.4.1 Manufacturer-specific
• READ: https://wiki.archlinux.org/title/CUPS/Printer-specific_problems
• HP drivers: hplip (Supported devices)
12.4.3 Scanner
https://wiki.archlinux.org/title/SANE
• Basic: sane
60/91
12.6 RGB Control
openrgbAUR: https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/Supported-Devices
12.7 Peripherals
12.7.1 Mice
List of flawless mice: https://sensor.fyi/mice/
Note: Mice like the ones from Zowie do not need any software to change the CPI.
12.7.2 Keyboards
Software Supported keyboards
qmk (Custom) keyboards: https://qmk.fm/keyboards/
61/91
12.8 Desktop-PC (DDR5) – Hardware Recommendations
12.8.1 Mainboard
• Sensor drivers often available (a bit later after release) for:
ASUS, ASRock?, Biostar?, Gigabyte?, MSI?
> https://wiki.archlinux.org/title/Lm_sensors#Troubleshooting
• NIC (Ethernet & Wireless): Intel > Realtek
12.8.3 CPU
12.8.3.1 Notes
• AVX-512 instructions can improve performance
• Minor performance degradation due to future microcode mitigations: AMD (-) > Intel (--)
12.8.4 Display
• Basic HDR support (in KDE Plasma 6) (HDR status)
• Overclocked panels ("OC mode") can cause issues
• DisplayPort (DP) > HDMI
12.8.5 Disk
• 4Kn ≥ 512e/4Kn > 512e > 512n …n = native, e = emulation (See: Advanced Format)
• External backup disk: Internal HDD + UASP USB case
62/91
13 Software specific
Note: You can take a look at my configuration files.
13.2 Zsh
https://wiki.archlinux.org/title/Zsh
chsh -s /usr/bin/zsh;
doas chsh -s /usr/bin/zsh;
63/91
13.4 Firefox
https://wiki.archlinux.org/title/Firefox
13.4.1 Installation
doas pacman -S --needed …
Firefox: firefox
Language packs: firefox-i18n-en-us firefox-i18n-de
Spell checker: hunspell hunspell-en_us hunspell-de
Password manager: keepassxc
64/91
13.4.4 Setup Firefox (using arkenfox user.js & uBlock Origin)
13.4.4.1 Goals
• Privacy & enhanced security
• Reduction of tracking & fingerprinting
• Side effects: Faster page load; Better battery, memory & network bandwidth usage
• Quality of Life
Note: You can take a look at my user-overrides.js (also with some QoL settings).
65/91
13.4.4.3 Search engines
In address bar: about:preferences#search
> Delete Search Shortcuts: Google, Bing, …
> Add a privacy-friendly search engine (→)
• https://www.startpage.com (uses Google search)
• https://searx.space (> choose a searx instance)
• https://metager.de (uses ~20-30 search engines)
• https://duckduckgo.com (USA, but has good keyboard
navigation)
13.4.4.4 Extensions
13.4.4.4.1 Basic
https://github.com/arkenfox/user.js/wiki/4.1-Extensions
• uBlock Origin – https://addons.mozilla.org/firefox/addon/ublock-origin/
• Skip Redirect – https://addons.mozilla.org/firefox/addon/skip-redirect/
Note: Deactivate for e.g. WiFi hotspot logins
• CanvasBlocker – https://addons.mozilla.org/firefox/addon/canvasblocker/
Note: For non-RFP users only (for my user-overrides.js)
> Only check Canvas & Audio APIs
13.4.4.4.2 Extras
• KDE Plasma Integration – https://addons.mozilla.org/firefox/addon/plasma-integration/
• KeePassXC-Browser – https://addons.mozilla.org/firefox/addon/keepassxc-browser/
Integration of the password manager KeePassXC
> In KeePassXC: Enable browser integration for Firefox
• LibRedirect – https://addons.mozilla.org/firefox/addon/libredirect/
Redirects YouTube, Twitter, Instagram, … to privacy friendly frontends and backends
• OPT: Violentmonkey – https://addons.mozilla.org/firefox/addon/violentmonkey/
User Script manager
• OPT: Binnen-I be gone – https://addons.mozilla.org/de/firefox/addon/binnen-i-be-gone/
For Germans: Filtert Binnen-Is
66/91
13.4.4.5 uBlock Origin: Hard mode (aka. block 3rd-party)
READ: https://github.com/gorhill/uBlock/wiki/Blocking-mode > Hard mode
READ: https://github.com/gorhill/uBlock/wiki/Quick-guide:-popup-user-interface
67/91
13.5 Gamemode (for low latency)
https://wiki.archlinux.org/title/Gamemode
gamemode lib32-gamemode
13.5.2 Configuration
wget -P ~/.config/
https://raw.githubusercontent.com/FeralInteractive/gamemode/master/example/
gamemode.ini;
vim ~/.config/gamemode.ini
> renice=10
13.5.3 Verify
Test config: gamemoded -t;
Start: gamemoderun <app>;
Verify: gamemoded -s
13.5.4 Notes
Firejail workaround:
firejail --ignore=noroot gamemoderun <app>
68/91
13.6 Monitoring system performance – MangoHud
https://wiki.archlinux.org/title/MangoHud
https://github.com/flightlessmango/MangoHud
mangohud lib32-mangohud
vim ~/.config/MangoHud/MangoHud.conf
> Uncomment:
13.6.1.1 VISUAL
# GPU
gpu_temp
gpu_core_clock
gpu_mem_clock
gpu_power
gpu_text=<gpu_name>
gpu_load_change
# CPU
cpu_temp
cpu_power
cpu_text=<cpu_name>
cpu_mhz
cpu_load_change
core_load
core_load_change
# RAM
vram
ram
histogram
gamemode
13.6.1.2 INTERACTION
# toggle_hud=Shift_R+F12
# toggle_logging=Shift_L+F2
13.6.1.3 LOG
output_folder=~/Games/mangologs
mkdir -p ~/Games/mangologs
69/91
13.6.2 Test configuration
mangohud glxgears
mangohud vkcube
13.6.3 Notes
• For some OpenGL apps: mangohud --dlsym <app>
70/91
13.7 Gaming
13.7.1 Steam
https://wiki.archlinux.org/title/Steam
steam lib32-libnm wqy-zenhei
71/91
13.8 Virtualization
https://wiki.archlinux.org/title/Category:Virtualization
GOAL: Set up KVM/QEMU > libvirt > Virt-Manager for default configuration.
Therefore, libvirt will be running on a system-level with default NAT/DHCP networking.
Note: Insert kernel parameters into e.g. /etc/cmdline.d/virtualization.conf
Setting Note
SEV – Secure Encrypted Virtualization
SEV - Secure Nested Paging (3rd gen) Should only be supported with Ryzen Pro,
Threadripper Pro & EPYC CPUs.
SEV - Encrypted State (2nd gen)
https://libvirt.org/kbase/launch_security_sev.html
SEV (1st gen)
SME – Secure Memory Encryption
SME Disabled by default since Linux 5.15.
Set kernel parameter mem_encrypt=on, but
problems can occur!
Transparent SME (aka. Memory Guard) For physical protection. Other memory encryption
features (like SEV) are then disabled. Use as a
fallback option.
Setting Note
TDX – Trust Domain Extensions ≥Xeon family: "Sapphire Rapids"
SGX2, SGX – Software Guard Extensions Even some consumer CPUs are supported.
72/91
13.8.2 KVM (Kernel-based Virtual Machine)
READ: https://wiki.archlinux.org/title/KVM
Note: "KVM is a hypervisor built into the Linux kernel. Unlike native QEMU, which uses emulation,
KVM is a special operating mode of QEMU that uses CPU extensions (HVM) for virtualization via a
kernel module."
73/91
13.8.4 libvirt (virtual machine manager)
READ: https://wiki.archlinux.org/title/Libvirt
READ: https://wiki.libvirt.org/page/FAQ
Note: "Libvirt now makes storage pools nocow when on btrfs automatically" – Source.
Note: Libvirt installs a zone called 'libvirt' in firewalld and manages its required network rules there.
13.8.4.1 Installation
Default NAT/DHCP networking:
doas pacman -S --needed --asdeps dnsmasq iptables-nft;
libvirt:
doas pacman -S libvirt;
74/91
13.8.4.5 Reboot (as an advice)
systemctl reboot
75/91
13.8.5 Virt-Manager (GUI Client)
READ: https://wiki.archlinux.org/title/Virt-Manager
virt-manager
13.8.5.1 Preferences
Edit > Preferences:
• General > Check: Enable XML editing
• New VM > x86 Firmware: UEFI
76/91
13.8.5.3 VM configuration (using QEMU/KVM)
Note: Before finishing the VM creation process > Check: "Customize configuration before install":
77/91
13.9 mpv (media player)
https://wiki.archlinux.org/title/mpv
https://github.com/mpv-player/mpv/wiki
… is stable, efficient, customizable and extensible via user scripts.
13.9.1 Installation
13.9.1.1 Dependencies
aria2 mpv-mpris yt-dlp
13.9.1.2 mpv
• w/ Vapoursynth (& SVP): vapoursynth libplacebo-git mpv-git svp-bin
13.9.2 Configuration
• User settings
~/.config/mpv/mpv.conf
78/91
13.10 OPT: Easy Effects (for EQ & more)
https://wiki.archlinux.org/title/PipeWire#EasyEffects
https://github.com/wwmm/easyeffects
easyeffects calf lsp-plugins-lv2
13.10.1 Presets
https://github.com/wwmm/easyeffects/wiki/Community-presets
79/91
13.11 Rust (using rustup, for devs)
https://wiki.archlinux.org/title/Rust
13.11.4 Editors
https://wiki.archlinux.org/title/Rust#Editors
• JetBrains IDE – RustRover (docs): rustroverAUR rustrover-jreAUR
80/91
14 Disks & Data
Change disk: /dev/sdb
Change disk name: myData (e.g.: "Vendor name" + "disk size" = e.g. Seagate20)
→dm_name: myData
→mount point: /mnt/myData (Change to e.g. "Data" for compatibility with future disks)
81/91
14.2.5 OPT: Choose a suitable zstd compression level (for mount)
14.2.5.1 Get test-package (Here: pacman package)
cp /var/cache/pacman/pkg/<package>.pkg.tar.zst /tmp/ && cd /tmp/;
unzstd <package>.pkg.tar.zst
14.2.5.2 Benchmark
for j in {1..15}; do zstd -b$j -T0 <package>.pkg.tar; done
14.2.5.3 Example
Package: libreoffice-still-7.3.6-4-x86_64.pkg.tar | Zstd version: v1.5.2
82/91
14.2.6 Get mount options (for fstab)
14.2.6.1 Mount the btrfs volume
READ: https://wiki.archlinux.org/title/Security#Mount_options
OPT – Increase compression level (≥4), change: compress=zstd:4
mount -m -o compress=zstd,nosuid,nodev,noexec /dev/mapper/myData /mnt/myData
vim /etc/crypttab
>
myData UUID=<blkid -o value -s UUID /dev/sdb> /etc/cryptsetup-
keys.d/myData.key
14.2.8.2 Fstab
https://wiki.archlinux.org/title/Fstab
Note – for Btrfs: fs_passno=0 instead of 2.
vim /etc/fstab
>
# myData
/dev/mapper/myData /mnt/myData btrfs <mount_options> 0 0
83/91
14.3 TODO – OPT: Directory structure of your private data
… for faster navigation.
• COLL/ – Collections (no music/video coll.)
• DWNLD/ – Downloads
• IMP/ – Important stuff
• MUSIC/ – Music coll.
• VID/ – Video coll.
84/91
14.4 TODO: Create a backup plan
https://wiki.archlinux.org/title/Synchronization_and_backup_programs
Recommendations:
• BorgBackup: borg
• restic: restic
14.4.1 Demands
• Type of backup medium: External hard drive
• Planned frequency of backups: Weekly, Monthly
• Important: Encrypted & Compressed storage; Handles FS metadata & renames
• Nice2Have: Resumable, Fast (Delta transfer, Multithreaded), Snapshots
• What will be backed up:
• Selected disks mounted on /mnt/
85/91
15 Maintenance
https://wiki.archlinux.org/title/System_maintenance
• Repeat:
• Jump to the next change: ] > c
• OPT: Get changes from other into current window: d > o (diff obtain)
86/91
15.3 Free up disk space
15.3.1 Tools (GUI)
https://wiki.archlinux.org/title/List_of_applications/Utilities#Disk_cleaning
• KDE disk usage statistics: filelight
87/91
16 Troubleshooting
READ: https://wiki.archlinux.org/title/General_troubleshooting
Note: You can always restore from a btrfs snapshot.
16.2.1 Logs
16.2.1.1 Error, critical & alert priority messages from last boot
journalctl -p3 -b-1
16.2.1.3 Pacman
cat /var/log/pacman.log
88/91
16.3 Useful keyboard shortcuts
16.3.1 Switch to n-th virtual console
… e.g. to avoid hard shutdowns (holding down the power button).
> Switch: Ctrl + Alt + Fn + { F1, F2, …, FN }
16.3.2.1 Enabling
doas vim /etc/sysctl.d/99-sysctl.conf
> kernel.sysrq = 128
16.3.2.2 Rebooting
"Reboot Even If System Utterly Broken":
Alt + Fn + Print + { R > E > I > S > U > B }
89/91
16.4 Pacman: "invalid or corrupted package PGP signature"
https://wiki.archlinux.org/title/Pacman/Package_signing#Upgrade_system_regularly
… if system upgrade has been delayed for an extended period of time.
doas pacman -Sy archlinux-keyring && doas pacman -Su;
90/91
17 TODOs
17.1 Additions
• Hardening of mount points
• dbus-broker
Currently does not have AppArmor support
• ukify tool to build, measure, and sign Unified Kernel Images (UKIs)
Currently experimental
• Trusted Platform Module (TPM)
• Better btrfs checksumming for collision resistance
• Maintainance: Old configuration files, Broken symlinks, List packages by date
• KDE Plasma 6 w/ Wayland
In February
• Restrict unprivileged user namespaces, but selectively allow for some apps (e.g. Steam) with
AppArmor's unprivileged_userns_restriction
Waiting for AppArmor v4 (also w/ dbus-broker support)
17.2 Deprecations
• Multilib repo (32-bit)
Waiting for Wine & thus also for Steam
• Xorg
Currently, no or incomplete implementation of Wayland in: KDE, OpenJDK (Java), Steam, …
91/91