LLI Wiki — My Digital Knowledge Base

Arch Linux maintenance routine

Weekly, fortnightly and monthly routine to keep an Arch Linux system up to date, clean and stable (Btrfs, LUKS, systemd).

A simple routine to keep an Arch Linux system (Btrfs, LUKS, Sway) clean, stable and up to date, without needlessly filling the disk.

1. Weekly routine

To do roughly once a week.

# Update the system
sudo pacman -Syu

# Clean the pacman cache, keeping old versions that may still be useful
sudo paccache -r

# Check disk space
df -h

# Check Btrfs space
sudo btrfs filesystem usage /

# Check for failed services
systemctl --failed

# Check swap
swapon --show
free -h

Reboot if the update concerns the kernel, systemd, Mesa, firmware, NetworkManager or Sway:

reboot

2. Every 15 days

To do roughly every two weeks.

# List orphaned packages
pacman -Qtd

# Show space used by systemd logs
journalctl --disk-usage

# Delete logs older than 2 weeks
sudo journalctl --vacuum-time=2weeks

# Show important errors from the current boot
journalctl -p err -xb

Remove orphaned packages only after reviewing the list shown by pacman -Qtd:

sudo pacman -Rns $(pacman -Qtdq)

If the list is empty, the removal command prints an error. This is harmless: there is simply nothing to remove.

3. Monthly routine

To do roughly once a month. Install firmware updates with the charger plugged in.

# Refresh firmware metadata and check for updates
fwupdmgr refresh --force
fwupdmgr get-updates

# Install firmware updates if available
sudo fwupdmgr update

# Btrfs scrub (verifies data and metadata) and its status
sudo btrfs scrub start -Bd /
sudo btrfs scrub status /

# Battery (requires TLP: sudo pacman -S tlp && sudo systemctl enable --now tlp)
sudo tlp-stat -b
upower -i $(upower -e | grep BAT)

# Check Btrfs subvolumes
sudo btrfs subvolume list /

Expected subvolumes after installation:

@
@home
@log
@pkg
@snapshots
@swap

4. After a major update

To do after a significant update of the kernel, firmware, Mesa, systemd or Sway:

reboot

# Check the running kernel
uname -r

# Check for failed services
systemctl --failed

5. Automatic cache cleaning

Install pacman-contrib, then enable automatic cleaning of the pacman cache:

sudo pacman -S pacman-contrib
sudo systemctl enable --now paccache.timer

# Check that the timer is active
systemctl list-timers | grep paccache

6. Useful commands

Task Command
Search for a package pacman -Ss package_name
Install a package sudo pacman -S package_name
List installed packages pacman -Q
Clean the cache more aggressively sudo paccache -rk1
Empty the whole cache (avoid unless needed) sudo pacman -Scc
Show memory and swap free -h
Show active swap swapon --show
Show LUKS information sudo cryptsetup luksDump /dev/nvme0n1p2
Add a second LUKS passphrase sudo cryptsetup luksAddKey /dev/nvme0n1p2
List firmware devices fwupdmgr get-devices
Limit logs to 500 MB sudo journalctl --vacuum-size=500M
Check the Sway configuration sway -C
Reload Sway swaymsg reload

7. TRIM for SSD and NVMe

On Arch, prefer the fstrim.timer timer over the discard option in /etc/fstab. With Btrfs and LUKS, this is generally the cleanest solution.

# Enable weekly TRIM
sudo systemctl enable --now fstrim.timer

# Check the status and the next run
systemctl status fstrim.timer
systemctl list-timers | grep fstrim

# Run TRIM manually once
sudo fstrim -av

# Check discard support
lsblk --discard

In the lsblk --discard output, the DISC-GRAN and DISC-MAX columns must be different from 0B for TRIM to be supported.

Notes

Mastodon LLIMastodon SocialFosstodon