From 6248fbc29a64f790c60edd91c4bcebf90253cf5d Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sat, 16 Sep 2023 14:03:26 +0200 Subject: [PATCH] btrfs scrub --- hosts/yodaTab/configuration.nix | 7 ------- hosts/yodaTux/configuration.nix | 7 ------- hosts/yodaYoga/configuration.nix | 7 ------- modules/base.nix | 36 +++++++++++++++++++++++++++++--- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/hosts/yodaTab/configuration.nix b/hosts/yodaTab/configuration.nix index 1e9be72..494d68d 100644 --- a/hosts/yodaTab/configuration.nix +++ b/hosts/yodaTab/configuration.nix @@ -49,13 +49,6 @@ in #../../modules/docker.nix ]; - # BTRFS compression. - # `nixos-generate-config` does not detect mount options, so we add them here. - # https://nixos.wiki/wiki/Btrfs#Compression - fileSystems = { - "/".options = [ "compress=zstd" ]; - }; - networking.hostName = "yodaTab"; services.openssh.ports = [ 22 ]; boot.initrd.network.ssh.port = 22; diff --git a/hosts/yodaTux/configuration.nix b/hosts/yodaTux/configuration.nix index e666ec3..94693b5 100644 --- a/hosts/yodaTux/configuration.nix +++ b/hosts/yodaTux/configuration.nix @@ -49,13 +49,6 @@ in ../../modules/docker.nix ]; - # BTRFS compression. - # `nixos-generate-config` does not detect mount options, so we add them here. - # https://nixos.wiki/wiki/Btrfs#Compression - fileSystems = { - "/".options = [ "compress=zstd" ]; - }; - networking.hostName = "yodaTux"; services.openssh.ports = [ 22 ]; boot.initrd.network.ssh.port = 22; diff --git a/hosts/yodaYoga/configuration.nix b/hosts/yodaYoga/configuration.nix index 9398c43..13da651 100644 --- a/hosts/yodaYoga/configuration.nix +++ b/hosts/yodaYoga/configuration.nix @@ -51,13 +51,6 @@ in ../../modules/docker.nix ]; - # BTRFS compression. - # `nixos-generate-config` does not detect mount options, so we add them here. - # https://nixos.wiki/wiki/Btrfs#Compression - fileSystems = { - "/".options = [ "compress=zstd" ]; - }; - networking.hostName = "yodaYoga"; services.openssh.ports = [ 2224 ]; boot.initrd.network.ssh.port = 2225; diff --git a/modules/base.nix b/modules/base.nix index fd1af4b..386571c 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -65,9 +65,39 @@ environment.systemPackages = with pkgs; [ ]; - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; + # BTRFS compression. + # + # `nixos-generate-config` does not detect mount options, so we add them here. + # https://nixos.wiki/wiki/Btrfs#Compression + fileSystems = { + "/".options = [ "compress=zstd" ]; + }; + + # BTRFS scrub. + # + # Scrubbing is the process of checking file consistency. + # Scrubbing may be done "online", meaning you don't need to unmount a subvolume to scrub it. + # https://nixos.wiki/wiki/Btrfs#Scrubbing + # Btrfs scrub is "[a]n online filesystem checking tool. Reads all the data and metadata on the filesystem and uses checksums and the duplicate copies from RAID storage to identify and repair any corrupt data." + # https://wiki.archlinux.org/title/btrfs#Scrub + # The scrub command operates on a whole filesystem, not just individual subvolumes. + # https://unix.stackexchange.com/a/724412 + # + # Manually: + # sudo btrfs scrub start / + # sudo btrfs scrub status / + # #=> UUID: 01f67928-9b35-48b2-aaa6-c58ff6c440a8 + # #=> Scrub started: Sat Sep 16 12:54:47 2023 + # #=> Status: finished + # #=> Duration: 0:00:42 + # #=> Total to scrub: 64.43GiB + # #=> Rate: 1.53GiB/s + # #=> Error summary: no errors found + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ "/" ]; + }; nix.settings.auto-optimise-store = true;