about summary refs log tree commit diff
path: root/users
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
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')
-rw-r--r--users/sterni/machines/edwin/default.nix1
-rw-r--r--users/sterni/modules/disk-checkup.nix25
2 files changed, 26 insertions, 0 deletions
diff --git a/users/sterni/machines/edwin/default.nix b/users/sterni/machines/edwin/default.nix
index 40700ea1e91b..ebf691c8d9ab 100644
--- a/users/sterni/machines/edwin/default.nix
+++ b/users/sterni/machines/edwin/default.nix
@@ -8,6 +8,7 @@
     ./hardware.nix
     ./network.nix
     # These modules configure services, websites etc.
+    ../../modules/disk-checkup.nix
     ./minecraft.nix
     ./gopher.nix
     ./http/sterni.lv.nix
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
+          )
+        );
+      };
+    };
+  };
+}