Skip to content

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

Bootloader
  GRUB = yes

Hostname

Hostname = <HOSTNAME>

Root account

Root passwort = none

User account

  • Create with sudo priviliges
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
- Wait for the installer to finish without error

Part 2: chroot-environment

chroot

chroot = yes

Fix fstab

  • remove from all btrfs-partitions
/etc/fstab
space_cache=v2,subvolid=<ID>
  • add to all btrfs-partitions
/etc/fstab
compress=zstd

Compress btrfs

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
/etc/xdg/reflector/reflector.conf
--Country <YOUR_COUNTRY>
--sort rate
systemctl enable reflector.timer

Exit chroot and reboot

exit
reboot

Part 3: Inside the new ArchLinux system

Check /etc/fstab

  • compress=zstd:3 and space_cache=v2 should be added automatically.
mount | grep home

Update the system

  • Check for Updates
sudo pacman -Syy
sudo pacman -Syu

KVM/QEMU

sudo pacman -S spice-vdagent
  • Reboot the system
reboot

Enable Arch User Repository (AUR)

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

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-btrfs doesn't work with systemd hook (issue #199)

  • Edit /etc/mkinitcpio.conf to change from systemd to udev:

    Change the following in HOOKS:
    replace systemd with udev
    replace sd-vconsole with keymap consolefont

    Change the following in BINARIES:
    add setfont

    Edit /etc/vconsole.conf
    FONT is missing and eurlatgr is 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
- Create a new configuration

sudo snapper -c root create-config /
- delete /.snapshots subvolume

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 /
- this should return somthing like

ID 5 (FS_TREE)
- we need to change that

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:
/etc/fstab
/swap/swapfile none swap defaults 0 0

Change permissions for snapper and /.snapshots

  • Allow members of wheel access to snapper
/etc/snapper/configs/root
ALLOW_GROUPS="wheel"
  • Allow members of wheel access to /.snapshots
sudo chown -R :wheel /.snapshots

Set snapshot limits

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