Maintenance and Troubleshooting
The administrator’s daily routine: keeping the fleet clean, intervening on a host, rolling back after a bad configuration, reading logs.
Acting on a host
Section titled “Acting on a host”All these commands target a host (or a pattern / list) via colmena:
| Command | Effect |
|---|---|
just enter <host> | Open an SSH shell (alias e) |
just reboot <host> | Reboot |
just halt <host> | Shut down |
just gc <host> [keep] | Purge generations + clean the store |
just fix-boot <host> | Reinstall the boot loader |
The keep argument of just gc limits the purge:
just gc <host>: keeps only the current generation.just gc <host> 3: keeps the last 3 generations, including the current one.just gc <host> 3d: removes generations older than 3 days.
Cleaning and formatting code
Section titled “Cleaning and formatting code”Before committing or deploying, normalize the repository:
just clean # fix + check + generate + formatjust check: code + unit tests + flake checks (before deployment).
Rollback
Section titled “Rollback”Each deployment creates a NixOS generation. In case of issues:
-
At boot : choose a previous generation from the boot menu.
-
Live rollback : revert to the previous generation then make it active:
Fenêtre de terminal just enter <host>sudo nixos-rebuild switch --rollback -
Through code :
git revertthe faulty configuration, then redeploy:Fenêtre de terminal just apply <host>
Reading logs
Section titled “Reading logs”just enter <host>journalctl -u <service> -n 100 --no-pager # logs d'un servicejournalctl -p err -b # erreurs depuis le démarragesystemctl status <service> # état d'une unitéServices failing after a gateway reboot
Section titled “Services failing after a gateway reboot”Symptom: systemctl --failed lists, right after boot, units that start back up
without a hitch once manually restarted (NFS mounts, OIDC provisioning, anything
that resolves a name).
Cause: on a gateway, the system resolver is AdGuard Home
(nameserver 127.0.0.1). Its unit is Type=simple, so systemd declares it
active as soon as the process starts — about twenty seconds before it actually
listens on port 53. Anything resolving a name during that window fails.
The framework puts up a barrier for this: dns-ready.service queries the local
resolver until it gets a response, and blocks nss-lookup.target until then.
systemctl status dns-ready # when names got resolvedjournalctl -b -u adguardhome | head -30 # when the DNS proxy finally listensA unit that resolves a name at boot must therefore order itself after this
target — after = [ "nss-lookup.target" ] for a service, the mount option
x-systemd.after=nss-lookup.target for a mount point. On non-gateway hosts,
the target is reached immediately: no added delay.
Expired TLS certificates on a gateway
Section titled “Expired TLS certificates on a gateway”A gateway does not request its own certificates: the HCS obtains them, and
the sync-caddy-certs unit copies them every ten minutes from the HCS to
the local Caddy storage.
systemctl status sync-caddy-certs # dernier passage et son résultatjournalctl -u sync-caddy-certs -n 50systemctl list-timers sync-caddy-certsThe transfer goes through two directories:
| Path | Role |
|---|---|
/var/lib/caddy-cert-sync | Staging area (StateDirectory of the unit) |
/var/lib/caddy/storage | Actual Caddy storage being served |
The unit runs as root, pulls from the HCS using the nix user’s SSH key,
then publishes to the Caddy storage. It first waits for the tailnet to be
actually mounted (up to five minutes), then retries the transfer three times
before giving up. A systemctl status showing failed therefore remains
the signal to watch, and a repeated failure indicates an expired certificate.
Misaligned gdm-greeter UIDs
Section titled “Misaligned gdm-greeter UIDs”Symptom, on every GNOME workstation startup:
warning: not applying UID change of user 'gdm-greeter-2' (60580 -> 60579)nixpkgs renumbered its gdm-greeter* accounts; NixOS never renumbers an existing
account. Workstations installed before keep the old UIDs, and two greeters can
end up sharing the same one.
just fix-gdm-greeters poste-01,poste-02 # diagnostic, writes nothingjust fix-gdm-greeters poste-01,poste-02 applyapply stops GDM, recreates the misaligned accounts with the declared UIDs,
reassigns their files, then restarts GDM. A host with an open graphical session
is left aside: restart after logging out. Backup of /etc/passwd and
/etc/shadow in /var/lib/nixos/backup-gdm-greeters-<date>/.