From c8385a466ef028a287525cb68c9c766f5b2902b1 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Tue, 21 Feb 2023 14:37:39 +0000 Subject: [PATCH] nixos/colony: Make fstrim happen right before backup --- lib/default.nix | 5 +++++ nixos/boxes/colony/default.nix | 1 + nixos/boxes/colony/vms/estuary/default.nix | 1 + nixos/boxes/colony/vms/shill/default.nix | 2 +- nixos/boxes/colony/vms/whale2/default.nix | 2 +- nixos/modules/server.nix | 12 ++++++++++++ 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 2b1b930..a4c6ea7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -254,6 +254,11 @@ rec { }; vip1 = "${start.vip1}4/30"; }; + fstrimConfig = { + enable = true; + # backup happens at 05:00 + interval = "04:45"; + }; }; sshKeyFiles = { me = ../.keys/me.pub; diff --git a/nixos/boxes/colony/default.nix b/nixos/boxes/colony/default.nix index c747f90..6818e0a 100644 --- a/nixos/boxes/colony/default.nix +++ b/nixos/boxes/colony/default.nix @@ -88,6 +88,7 @@ }; services = { + fstrim = lib.my.colony.fstrimConfig; lvm = { boot.thin.enable = true; dmeventd.enable = true; diff --git a/nixos/boxes/colony/vms/estuary/default.nix b/nixos/boxes/colony/vms/estuary/default.nix index 225fe53..5b05578 100644 --- a/nixos/boxes/colony/vms/estuary/default.nix +++ b/nixos/boxes/colony/vms/estuary/default.nix @@ -91,6 +91,7 @@ in }; services = { + fstrim = lib.my.colony.fstrimConfig; lvm = { dmeventd.enable = true; }; diff --git a/nixos/boxes/colony/vms/shill/default.nix b/nixos/boxes/colony/vms/shill/default.nix index 5f22db4..1d45648 100644 --- a/nixos/boxes/colony/vms/shill/default.nix +++ b/nixos/boxes/colony/vms/shill/default.nix @@ -92,7 +92,7 @@ }; services = { - fstrim.enable = true; + fstrim = lib.my.colony.fstrimConfig; netdata.enable = true; }; diff --git a/nixos/boxes/colony/vms/whale2/default.nix b/nixos/boxes/colony/vms/whale2/default.nix index 827412f..73edf65 100644 --- a/nixos/boxes/colony/vms/whale2/default.nix +++ b/nixos/boxes/colony/vms/whale2/default.nix @@ -93,7 +93,7 @@ in }; services = { - fstrim.enable = true; + fstrim = lib.my.colony.fstrimConfig; netdata.enable = true; }; diff --git a/nixos/modules/server.nix b/nixos/modules/server.nix index 49acde3..f3d994f 100644 --- a/nixos/modules/server.nix +++ b/nixos/modules/server.nix @@ -14,6 +14,18 @@ in kmscon.autologinUser = mkDefault uname; resolved.llmnr = mkDefault "false"; }; + systemd = { + timers = { + fstrim = mkIf config.services.fstrim.enable { + timerConfig = { + # Upstream unit has these at crazy high values that probably + # make sense on desktops / laptops + AccuracySec = "1min"; + RandomizedDelaySec = "5min"; + }; + }; + }; + }; my = { gui.enable = false;