Arch Linux: UEFI install with LUKS, Btrfs, XFCE and Timeshift
Arch Linux UEFI install with LUKS-encrypted root, Btrfs subvolumes, GRUB, XFCE, Timeshift and console troubleshooting.
This memo covers an Arch Linux install on UEFI with an encrypted root partition (LUKS), Btrfs with subvolumes (for Timeshift snapshots), GRUB and the XFCE desktop. Disable Secure Boot in the BIOS to boot from the USB stick, and make sure you booted in UEFI mode.
Pre-checks
loadkeys fr
# If this directory exists, the system booted in UEFI mode
ls /sys/firmware/efi/efivars
# Network
ip addr show
ping -c 2 example.com
lsblk
Wi-Fi with iwd:
iwctl
[iwd]# device list
[iwd]# station <device> scan
[iwd]# station <device> get-networks
[iwd]# station <device> connect <SSID>
Partitioning and encryption
# Wipe the disk (optional, slow)
shred -v -n 1 /dev/sda
gdisk /dev/sda
Create a GPT table with two partitions:
/dev/sda1 EFI ef00 512 MB
/dev/sda2 Linux 8300
mkfs.fat -F32 /dev/sda1
cryptsetup --cipher aes-xts-plain64 --hash sha512 --use-random --verify-passphrase luksFormat /dev/sda2
cryptsetup luksOpen /dev/sda2 root
mkfs.btrfs /dev/mapper/root
Btrfs subvolumes
mount /dev/mapper/root /mnt
cd /mnt
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @snapshots
cd /
umount /mnt
mount -o noatime,space_cache=v2,compress=zstd,ssd,discard=async,subvol=@ /dev/mapper/root /mnt
mkdir /mnt/{boot,home,.snapshots}
mkdir /mnt/boot/efi
mount -o noatime,space_cache=v2,compress=zstd,ssd,discard=async,subvol=@home /dev/mapper/root /mnt/home
mount -o noatime,space_cache=v2,compress=zstd,ssd,discard=async,subvol=@snapshots /dev/mapper/root /mnt/.snapshots
mount /dev/sda1 /mnt/boot/efi
Base system
pacstrap /mnt base linux linux-firmware btrfs-progs git vim intel-ucode ntp
genfstab -L -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
In /etc/mkinitcpio.conf, the HOOKS line must contain encrypt (before filesystems) and btrfs:
HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt filesystems btrfs fsck)
mkinitcpio -P
Locale configuration
vim /etc/hostname
vim /etc/locale.gen # uncomment en_US.UTF-8 UTF-8 and fr_FR.UTF-8 UTF-8
locale-gen
/etc/locale.conf:
LANG="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
/etc/vconsole.conf (French AZERTY keyboard, or Belgian with be-latin1):
KEYMAP=fr-pc
FONT=
FONT_MAP=
export LANG=fr_FR.UTF-8
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
timedatectl set-ntp true
hwclock --systohc
passwd
Additional packages
pacman -S grub efibootmgr networkmanager network-manager-applet dialog wpa_supplicant reflector \
base-devel linux-headers avahi xdg-user-dirs xdg-utils gvfs gvfs-smb nfs-utils inetutils dnsutils \
cups alsa-utils pipewire pipewire-alsa pipewire-pulse pipewire-jack pavucontrol bash-completion \
openssh rsync acpi acpi_call tlp ipset ufw sof-firmware nss-mdns acpid ntfs-3g terminus-font nano \
man-db man-pages zip p7zip unzip tar htop tmux wget pciutils lshw syslog-ng
Graphics drivers (depending on hardware, for example mesa, xf86-input-libinput) and, for virtualization:
pacman -S qemu qemu-arch-extra edk2-ovmf bridge-utils dnsmasq vde2 openbsd-netcat
GRUB with an encrypted root partition
In /etc/default/grub:
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root root=/dev/mapper/root rootflags=subvol=@ rw quiet"
GRUB_ENABLE_CRYPTODISK=y
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
Services, user and reboot
systemctl enable NetworkManager cups.service sshd avahi-daemon tlp reflector.timer libvirtd acpid ufw
useradd -m app_user
passwd app_user
usermod -aG libvirt app_user
echo "app_user ALL=(ALL) ALL" >> /etc/sudoers.d/app_user
exit
umount -R /mnt
reboot
Post-installation
ip a
nmtui # Wi-Fi through NetworkManager
sudo pacman -Sy
Install the AUR helper yay, then Timeshift (automatic snapshots before updates) and zramd (compressed swap in RAM):
mkdir sources && cd sources
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
yay -S timeshift-autosnap zramd
sudo systemctl enable zramd.service
lsblk # check that swap is active
Pacman mirrors:
reflector --verbose --country 'France' -a 6 --sort rate --save /etc/pacman.d/mirrorlist
sudo pacman -Syy
XFCE desktop
sudo pacman -S xfce4 xfce4-goodies lightdm-gtk-greeter-settings gtk-xfce-engine
sudo systemctl enable lightdm
In /etc/lightdm/lightdm.conf, section [Seat:*]:
greeter-session = lightdm-gtk-greeter
echo "exec startxfce4" > ~/.xinitrc
sudo pacman -S ttf-dejavu ttf-bitstream-vera adobe-source-han-sans-otc-fonts noto-fonts noto-fonts-emoji ttf-liberation ttf-droid tex-gyre-fonts
# Multimedia codecs (GStreamer plugins)
sudo pacman -S gst-plugins-{base,good,bad,ugly} gst-libav
sudo pacman -S chromium
For Pinyin input, use fcitx.
ufw firewall
sudo ufw logging on
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw reload
Backup
gvfs-smb lets Thunar browse Samba shares (smb://192.0.2.10, after a reboot). For encrypted, incremental backups, deja-dup (a graphical front end for duplicity) is the simplest; Borg or rsync are alternatives.
Console troubleshooting (keyboard, font, firmware)
- Missing firmware during
mkinitcpio: see the Possibly missing firmware section of the Arch wiki (AUR orlinux-firmware-*packages). - List keymaps:
localectl list-keymaps, thenloadkeys be-latin1to test. - Persistent setting in
/etc/vconsole.conf(for exampleKEYMAP=be-latin1,FONT=lat2-16,FONT_MAP=8859-2), thensudo mkinitcpio -P. - Available fonts:
ls /usr/share/kbd/consolefonts/. - Error
setfont: KDFONTOP: Function not implemented: see kbd issue #99; the fix noted is to replace thekeymap consolefonthooks withsd-vconsolein/etc/mkinitcpio.conf(systemd-based initramfs).
Notes
- LUKS encryption with Btrfs and GRUB can be problematic depending on the LUKS version;
systemd-bootis an alternative worth investigating. - Secure Boot must stay disabled with this setup.