Installing Arch Linux
In this guide we’ll walk through how I like to set up Arch Linux. The configured system will have the fallowing features:
- Btrfs filesystem
- Secure boot
- UKI EFI boot
- Encrypted root partition unlocked with TPM module
- Separate UKI entries for snapshots taken before updates
Getting Ready
Update the System Clock
First start by updating the system clock:
timedatectl set-timezone Europe/BerlinDisk Setup
Identify your disk:
lsblkCreate partitions:
echo -e "label: gpt\n,512M,U\n,8G,S\n,,L" | sfdisk /dev/nvme0n1This creates:
- 512M EFI boot partition
- 8G swap partition
- Remaining space for Linux filesystem
Format partitions:
mkfs.fat -F32 -n 'ARCH BOOT' /dev/nvme0n1p1mkswap -L 'Arch Swap' /dev/nvme0n1p2mkfs.btrfs -L 'Arch OS' /dev/nvme0n1p3Create partitions for encryption:
echo -e "label: gpt\n,512M,U\n,8G,L\n,,L" | sfdisk /dev/nvme0n1Set up LUKS encryption:
cryptsetup luksFormat -v -s 512 -h sha512 --type luks2 /dev/nvme0n1p2cryptsetup luksFormat -v -s 512 -h sha512 --type luks2 /dev/nvme0n1p3cryptsetup open /dev/nvme0n1p2 Arch-Swapcryptsetup open /dev/nvme0n1p3 Arch-OSFormat encrypted partitions:
mkfs.fat -F32 -n 'ARCH BOOT' /dev/nvme0n1p1mkswap -L 'Arch Swap' /dev/mapper/Arch-Swapmkfs.btrfs -L 'Arch OS' /dev/mapper/Arch-OSSetting up Btrfs
It is recommended to create subvolumes for the root partition. An example layout is:
Directory@ mounted at /
- @home mounted at /home
- @log mounted at /var/log
- @pkg mounted at /var/cache/pacman/pkg
- @snapshots mounted at /.snapshots
- @nocow mounted at /nocow
mount /dev/nvme0n1p3 /mntbtrfs subvolume create /mnt/@btrfs subvolume create /mnt/@homebtrfs subvolume create /mnt/@logbtrfs subvolume create /mnt/@pkgbtrfs subvolume create /mnt/@snapshotsbtrfs subvolume create /mnt/@nocowumount /mntmount /dev/mapper/Arch-OS /mntbtrfs subvolume create /mnt/@btrfs subvolume create /mnt/@homebtrfs subvolume create /mnt/@logbtrfs subvolume create /mnt/@pkgbtrfs subvolume create /mnt/@snapshotsbtrfs subvolume create /mnt/@nocowumount /mntMount the Filesystems
mount -o subvol=@,ssd,compress=zstd:2 /dev/nvme0n1p3 /mntmkdir -p /mnt/{boot,efi/EFI/Linux,home,var/{log,cache/pacman},.snapshots,nocow}mount -o subvol=@home,compress=zstd:2 /dev/nvme0n1p3 /mnt/homemount -o subvol=@log,compress=zstd:2 /dev/nvme0n1p3 /mnt/var/logmount -o subvol=@pkg,compress=zstd:2 /dev/nvme0n1p3 /mnt/var/cache/pacmanmount -o subvol=@snapshots,compress=zstd:2 /dev/nvme0n1p3 /mnt/.snapshotsmount -o subvol=@nocow,nodatacow /dev/nvme0n1p3 /mnt/nocowmount /dev/nvme0n1p1 /mnt/efiswapon /dev/nvme0n1p2mount -o subvol=@,ssd,compress=zstd:2 /dev/mapper/Arch-OS /mntmkdir -p /mnt/{boot,efi/EFI/Linux,home,var/{log,cache/pacman},.snapshots,nocow}mount -o subvol=@home,compress=zstd:2 /dev/mapper/Arch-OS /mnt/homemount -o subvol=@log,compress=zstd:2 /dev/mapper/Arch-OS /mnt/var/logmount -o subvol=@pkg,compress=zstd:2 /dev/mapper/Arch-OS /mnt/var/cache/pacmanmount -o subvol=@snapshots,compress=zstd:2 /dev/mapper/Arch-OS /mnt/.snapshotsmount -o subvol=@nocow,nodatacow /dev/mapper/Arch-OS /mnt/nocowmount /dev/nvme0n1p1 /mnt/efiswapon /dev/mapper/Arch-SwapThis should result in the following mount points:
Directory/mnt
Directoryefi/
DirectoryEFI/
DirectoryLinux/
- …
Directoryhome/
- …
Directoryvar/
Directorylog/
- …
Directorycache/
Directorypacman/
- …
Directory.snapshots/
- …
Directorynocow/
- …
Installing Linux
Start with updating the mirrors:
reflector --latest 5 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlistInstall Base System
Install the essential base packages:
pacstrap -K /mnt base linux linux-firmware sudo git base-devel rustThese packages provide:
base: Minimal base systemlinux: Linux kernellinux-firmware: Hardware firmwaresudo: Allows privilege escalation for administrative tasksgit,base-devel,rust: Required for building AUR packages later
Configuring the System
First start by generating the fstab:
genfstab -U /mnt >> /mnt/etc/fstabConfigure basic system settings with systemd-firstboot:
systemd-firstboot --root /mnt \ --hostname=emirhans-laptop \ --locale=en_US.UTF-8 \ --keymap=us \ --timezone=Europe/BerlinNow you can chroot into the new system:
arch-chroot /mntConfigure Pacman
First, configure pacman settings and enable multilib repository:
sed -i 's/#Color/Color/' /etc/pacman.confsed -i 's/#VerbosePkgLists/VerbosePkgLists/' /etc/pacman.confsed -i 's/ParallelDownloads = 5/ParallelDownloads = 10/' /etc/pacman.confsed -i '/^\[options\]/a ILoveCandy' /etc/pacman.conf
# Enable multilib repositorysed -i '/^#\[multilib\]/,/^#Include.*mirrorlist/ s/^#//' /etc/pacman.conf
# Update package databasepacman -SySetting up the System
Generate additional locales and set up users:
# Generate additional localesecho 'de_DE.UTF-8 UTF-8' >> /etc/locale.genecho 'en_DK.UTF-8 UTF-8' >> /etc/locale.genecho 'en_GB.UTF-8 UTF-8' >> /etc/locale.genecho 'en_IE.UTF-8 UTF-8' >> /etc/locale.genecho 'en_US.UTF-8 UTF-8' >> /etc/locale.genecho 'tr_TR.UTF-8 UTF-8' >> /etc/locale.genlocale-genSetting up Users
Start by setting the root password:
passwdThis will prompt you to enter a new password for the root user. After entering the password twice you can continue by creating a non-root user:
# First create groups some system groupsgroupadd -r storagegroupadd -r powergroupadd -r plugdevuseradd -m -G wheel,storage,power,plugdev -s /bin/bash emirhan# Set the password for the userpasswd emirhanEnable sudo for the wheel group:
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoersNow we can switch to the new user for the rest of the installation:
su emirhanOptimize Build Configuration
Configure makepkg to use all available CPU cores for faster compilation:
sudo sed -i 's/#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/' /etc/makepkg.confThis replaces the default #MAKEFLAGS="-j2" with MAKEFLAGS="-j$(nproc)" to utilize all available CPU cores.
Install AUR Helper
Install paru to manage AUR packages:
cd $(mktemp -d)git clone https://aur.archlinux.org/paru.gitcd parumakepkg -siInstall Additional Packages
Now that we have the AUR helper set up, install additional packages and AUR packages using the package selector:
📦 Customize Package Selection
paru -S --neededConfigure Installed Packages
Configure reflector and enable services:
# Configure reflectorsudo tee /etc/xdg/reflector/reflector.conf > /dev/null <<EOF--save /etc/pacman.d/mirrorlist--protocol https--latest 5--sort rateEOF
# Enable reflector timersudo systemctl enable reflector.timer
# Enable services (after packages are installed)sudo systemctl enable NetworkManagersudo systemctl enable bluetooth.service
# Enable display manager (choose one based on what you installed)sudo systemctl enable sddm.service # For SDDM (KDE-based)# sudo systemctl enable gdm.service # For GDM (GNOME-based)
# Change shell to zsh (if zsh was installed)chsh -s /bin/zshConfiguring the Bootloader
There are multiple bootloaders you can use. The most common ones are GRUB and systemd-boot. You can find documentation on how to configure these bootloaders also in my wiki under the Arch Linux section. We are going to configure BIOS to boot directly into linux kernel. But it is recommended to configure some bootloader as a fallback option or in case your motherboard does not support booting directly into the kernel.
Setting up Firewall
If you were fallowing the guide you should have installed firewalld too. You can enable and configure it, here is an example configuration:
sudo systemctl enable firewalldsudo firewall-cmd --set-default-zone=dropsudo firewall-cmd --zone=drop --add-service=dhcpv6-client --permanentsudo firewall-cmd --zone=drop --add-service=dns --permanentsudo firewall-cmd --zone=drop --add-service=dns-over-quic --permanentsudo firewall-cmd --zone=drop --add-service=dns-over-tls --permanentsudo firewall-cmd --zone=drop --add-service=http --permanentsudo firewall-cmd --zone=drop --add-service=htt3 --permanentsudo firewall-cmd --zone=drop --add-service=https --permanentsudo firewall-cmd --zone=drop --add-service=ntp --permanentsudo firewall-cmd --zone=drop --add-service=openvpn --permanentsudo firewall-cmd --zone=drop --add-service=samba-client --permanentsudo firewall-cmd --zone=drop --add-service=spotify-sync --permanentsudo firewall-cmd --zone=drop --add-service=wireguard --permanentsudo firewall-cmd --zone=trusted --change-interface=lo --permanentThere is also a GUI for firewalld called firewall-config which should be already installed.