From b4c0c40f6399c77bc8bedc596038410fa2f79c56 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 6 Sep 2022 19:04:32 +0200 Subject: feat(sterni/machines/edwin): enable btrfs autoscrub 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 Tested-by: BuildkiteCI --- users/sterni/machines/edwin/default.nix | 1 + users/sterni/modules/disk-checkup.nix | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 users/sterni/modules/disk-checkup.nix diff --git a/users/sterni/machines/edwin/default.nix b/users/sterni/machines/edwin/default.nix index 40700ea1e9..ebf691c8d9 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 0000000000..8acc08759b --- /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 + ) + ); + }; + }; + }; +} -- cgit 1.4.1