From d9208f492baad721eca4ce1ab1c00260df53e886 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sat, 3 Oct 2026 09:42:14 +0800 Subject: [PATCH] fix(preservation): keep logrotate state in a persisted directory --- hosts/idols-ai/preservation.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hosts/idols-ai/preservation.nix b/hosts/idols-ai/preservation.nix index d68fa279..2d11a5ed 100644 --- a/hosts/idols-ai/preservation.nix +++ b/hosts/idols-ai/preservation.nix @@ -101,6 +101,10 @@ in "/var/lib/NetworkManager" "/var/lib/iwd" "/var/lib/tailscale" + + # logrotate state. Persist the directory: a single-file bind mount cannot + # be replaced by logrotate's atomic rename() (EBUSY). + "/var/lib/logrotate" ]; files = [ # auto-generated machine ID @@ -108,10 +112,6 @@ in file = "/etc/machine-id"; inInitrd = true; } - # logrotate's state file (a regular file, not a directory). It records the - # last rotation per log; a missing entry makes logrotate treat the log as - # freshly rotated, so the state must survive reboots. - { file = "/var/lib/logrotate.status"; } ]; # the following directories will be passed to /persistent/home/$USER @@ -373,6 +373,13 @@ in }; }; + # Keep logrotate's state inside the directory preserved above instead of the + # default /var/lib/logrotate.status (a mount point `rename()` cannot replace). + services.logrotate.extraArgs = [ + "--state" + "/var/lib/logrotate/status" + ]; + # Create some directories with custom permissions. # # In this configuration the path `/home/butz/.local` is not an immediate parent