Archlinux with btrfs and snapper on GNOME
Pre-installation
This guide assumes that you already booted into your live environment as described in the Archlinux Installation guide.
To keep things simple, archinstall is used.
Part 1: Installation
Keyboard layout
- This guide is centered around the german language. If you need another keyboard layout, change the commands accordingly.
loadkeys de-latin1
Wifi
iwctl device list
iwctl station <DEVICE> scan
iwctl station <DEVICE> get-networks
iwctl --passphrase=<PASSPHRASE> station <DEVICE> connect <SSID>
Start the installer
archinstall
Language of the installer
Archinstall language = English
German language pack
Keyboard layout = de
Mirror region = Germany
Locale Language = de_DE.UTF-8
Locale encoding = UTF-8
Drive to install the system to (I assume you know your drives?!)
Drives = <CHOOSE_YOUR_INSTALL_DRIVE>
Disk layout
Disk layout = <HERE BE DRAGONS>
First partition
fat32
startlocation = 1MiB
endlocation = 4098MiB
mountpoint = /boot
Second partition
btrfs
startlocation = 4099MiB
endlocation = 100%
btrfs subvolumes
Subvolumes
#escape out of compress, archinstall doesn't enable it anyway (2023-06-2023)
@ = /
@home = /home
@swap = /swap
@snapshots = /.snapshots
@var_log = /var/log
@pkg = /var/cache/pacman/pkg
@images = /var/lib/libvirt/images
# IMPORTANT
nodatacow = yes
# gdm needs to be rw if we boot from snapshots
# This is why we make the following subvolumes
@AccountsService = /var/lib/AccountsService
@gdm = /var/lib/gdm
The subvolumes @AccontService and @gdm will ensure that gdm works if booted into a snapshot and no overlayfs is present.
Bootloader
- GRUB since we will use
grub-btrfsto create bootmenus for snapshots
Bootloader
GRUB = yes
Hostname
Hostname = <HOSTNAME>
Root account
Root passwort = none
User account
- Create with
sudopriviliges
User account
Add a user
Enter username = <USERNAME>
Password = <PASSWORT>
Superuser = yes
GNOME and open-source graphic driver
Profile
desktop
gnome
Graphics driver = All open-source
Audio-backend
Audio = pipewire
Kernel
Kernels = linux-zen
Additional packages
[amd|intel]-ucode cups firefox firefox-i18n-de flatpak git inotify-tools nano noto-fonts reflector ttf-dejavu ttf-jetbrains-mono ttf-liberation dconf-editor file-roller p7zip unrar gedit gedit-plugins seahorse gnome-terminal gnome-tweaks libreoffice-fresh libreoffice-fresh-de meld gimp inkscape gparted dosfstools btrfs-progs ntfs-3g polkit gpart mtools xorg-xhost vlc lib32-gnutls wine
Networking
Network configuration = NetworkManager
Timezone
Timezone = Europe/Berlin
Optional repositories
Optional repositories = multilib
Start the installation
No way back after this point.
Install
Part 2: chroot-environment
chroot
chrootinto the new system
chroot = yes
Fix fstab
- remove from all btrfs-partitions
space_cache=v2,subvolid=<ID>
- add to all btrfs-partitions
compress=zstd
Compress btrfs
- The filesystem is still uncompessed
btrfs filesystem defragment -r -v -czstd /
Enable systemd services
- Archlinux doesn't enable these systemd services by default
systemctl enable avahi-daemon
systemctl enable bluetooth
systemctl enable cups
systemctl enable upower
systemctl enable sshd
Configure and enable Reflector
- Uncomment and change
--Country <YOUR_COUNTRY>
--sort rate
- enable systemd timer
systemctl enable reflector.timer
Exit chroot and reboot
exit
reboot
Part 3: Inside the new ArchLinux system
Check /etc/fstab
compress=zstd:3andspace_cache=v2should be added automatically.
mount | grep home
Update the system
- Check for Updates
sudo pacman -Syy
sudo pacman -Syu
KVM/QEMU
- If the system resides within a virtual machine, enable dynamic resolution and clipboard-sharing
sudo pacman -S spice-vdagent
- Reboot the system
reboot
Enable Arch User Repository (AUR)
- Take a look at the yay Installation guide
git clone https://aur.archlinux.org/yay
cd yay
makepkg -si
cd ..
rm -rf yay
yay -Y --gendb #generate a development package database for *-git packages
yay -Syu --devel
yay -Y --devel --combinedupgrade --batchinstall --editmenu --nodiffmenu --save
Create and manage snapshots
- Install the
snapper-supportmetapackage. This will pull and configuresnapper,grub-btrfsandsnap-pac.
yay -S snapper-support
IMPORTANT
snapper-support fails to create a btrfs subvolume.This is expected.Go to Fix snapshots
grub-btrfs doesn't work with systemd (issue #199).This is expected.Go to Fix initial ramdisk
Fix initial ramdisk
grub-btrfsdoesn't work withsystemdhook (issue #199)-
Edit
/etc/mkinitcpio.confto change from systemd to udev: Change the following inHOOKS: replacesystemdwithudevreplacesd-vconsolewithkeymap consolefontChange the following inBINARIES: addsetfontEdit/etc/vconsole.confFONT is missing andeurlatgris a better default console font for European based languages.)FONT=eurlatgr -
Regenerate initial ramdisk
sudo mkinitcpio -P
Fix snapshots
- Umount and delete ./snapshots
sudo umount /.snapshots
sudo rm -r /.snapshots
sudo snapper -c root create-config /
sudo btrfs subvolume delete /.snapshots
- check if /.snapshots is gone and @snapshots is present
sudo btrfs subvolume list /
- create and mount /.snapshots
sudo mkdir /.snapshots
sudo mount -av
- A good practice is to reboot now
reboot
Change btrfs default subvolume to @
- The default subvolume should not point to '/'
sudo btrfs subvol get-default /
ID 5 (FS_TREE)
sudo btrfs subvol list /
# take a note of the ID of subvolume @ (possibly 256)
# change the command accordingly
sudo btrfs subvolume set-default 256 /
# check again with
sudo btrfs subvol get-default /
Enable swap
@swap is already mounted at /swap. See Chapter 8. Disk layout
- create a swapfile
btrfs filesystem mkswapfile --size 4g --uuid clear /swap/swapfile
swapon /swap/swapfile
- edit the fstab configuration to add an entry for the swap file:
/swap/swapfile none swap defaults 0 0
Change permissions for snapper and /.snapshots
- Allow members of
wheelaccess to snapper
ALLOW_GROUPS="wheel"
- Allow members of
wheelaccess to /.snapshots
sudo chown -R :wheel /.snapshots
Set snapshot limits
- Set limits to the Arch-wiki recommendation
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_WEEKLY="0"
TIMELINE_LIMIT_MONTHLY="0"
TIMELINE_LIMIT_YEARLY="0"
Preventing slowdowns
- See preventing slowdowns in the Arch-wiki