This document summarizes an immutable /usr setup using
systemd-sysext, with selective immutability in /var and safe
handling of pacman during development and testing.
- Prevent accidental system drift
- Make
/usrimage-like and reproducible - Use
systemd-sysextas the only mutation path for/usr - Fail fast if tools try to mutate the base system
- Keep Arch flexibility without turning it into a full immutable distro
- /usr → system image (immutable)
- /etc → configuration (mutable)
- /var → state (mutable, selectively constrained)
- /run → runtime (tmpfs)
- /home → user data
- Mounted read-only from boot
- Never written to directly
- Extended only via
systemd-sysext - No
chattr +i(breaks overlayfs)
- Writable
- Managed manually
.pacnew/.pacsaveexpected
- Writable by default
- Treated as state, not system
- Selected subpaths may be RO or tmpfs
- Designed for immutable
/usr - Uses overlayfs
- Base
/usrremains untouched - Extensions provide additive
/usrtrees
/usrmust be immutable via mounts, not FS flags/runmust be writable- Extension source directory must be writable
- e.g.
/run/extensions
- e.g.
/usrdoes not need to be writable/vardoes not need to be immutable
pacman is a system mutation tool and is incompatible with an
immutable /usr during sysext usage.
- Never run
pacmanwhile sysext is merged - Build packages, don’t install them
- Extract
/usrfrom packages into sysext trees
To prevent accidental mutation:
- Bind-mount
/var/lib/pacmanto itself - Remount it read-only
Result:
pacmanfails immediately- No DB writes
- No hooks
- No partial state
This lock is temporary and reversed when sysext is unmerged.
| Path | Treatment | Reason |
|---|---|---|
/var/lib/pacman |
bind RO | block pacman safely |
/var/cache/pacman |
tmpfs / RW | disposable cache |
/var/log |
RW / tmpfs | logging |
/var/tmp |
tmpfs | transient state |
/var/lib/systemd |
RW | systemd state |
Do not make all of /var immutable.
- Strong system integrity
- Clear separation of image vs state
- Predictable behavior
- Easy rollback (
sysext unmerge) - Fail-fast errors instead of silent corruption
- A beginner-friendly Arch setup
- A fully immutable OS
- Compatible with ad-hoc
pacman -Sworkflows
- /usr = image (immutable)
- /etc = policy
- /var = state
If /usr changes, it was intentional.
This approach provides most of the safety of an immutable OS while retaining Arch Linux flexibility, using standard kernel and systemd features without filesystem hacks.
It is advanced, opinionated, and powerful — by design.