about summary refs log tree commit diff
path: root/users/sterni/modules/disk-checkup.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-09-06T17·04+0200
committersterni <sternenseemann@systemli.org>2022-11-26T15·51+0000
commitb4c0c40f6399c77bc8bedc596038410fa2f79c56 (patch)
tree205c29c8efb440ed08e825c48ddb1e468bc10b40 /users/sterni/modules/disk-checkup.nix
parent2490ce968c73181d383b297c2e473605d8ac96c3 (diff)
feat(sterni/machines/edwin): enable btrfs autoscrub r/5337
Small module that regularly runs btrfs scrub on all btrfs filesystems.
Eventually the module should also do SMART value monitoring, as edwin is
a server from Hetzner's server auction, so a disk failure may not be too
far away.

Change-Id: I11e423a5d91c99ad455c2bb29b632efb79ef908e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7294
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/sterni/modules/disk-checkup.nix')
-rw-r--r--users/sterni/modules/disk-checkup.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/users/sterni/modules/disk-checkup.nix b/users/sterni/modules/disk-checkup.nix
new file mode 100644
index 000000000000..8acc08759b17
--- /dev/null
+++ b/users/sterni/modules/disk-checkup.nix
@@ -0,0 +1,25 @@
+# TODO(sterni): configure smartd and alerts
+{ config, lib, ... }:
+
+{
+  config = {
+    services = {
+      btrfs.autoScrub = {
+        enable = true;
+        interval = "daily";
+        # gather all btrfs fileSystems and overwrite default
+        fileSystems = lib.mkForce (
+          lib.concatLists (
+            lib.mapAttrsToList
+              (
+                _:
+                { fsType, mountPoint, ... }:
+                if fsType == "btrfs" then [ mountPoint ] else [ ]
+              )
+              config.fileSystems
+          )
+        );
+      };
+    };
+  };
+}