From 75c20bc6f0c8a3a2b6ae0a0630d55d3adf8780ba Mon Sep 17 00:00:00 2001 From: Kabbone Date: Fri, 13 Jan 2023 17:21:18 +0100 Subject: [PATCH] hosts: add btrfs scrub and snapper for all --- hosts/configuration_desktop.nix | 9 -- hosts/desktop/hardware-configuration.nix | 23 ++++ hosts/laptop/hardware-configuration.nix | 23 ++++ hosts/nas/hardware-configuration.nix | 162 +++++++++++++++++++++++ hosts/server/hardware-configuration.nix | 23 ++++ 5 files changed, 231 insertions(+), 9 deletions(-) diff --git a/hosts/configuration_desktop.nix b/hosts/configuration_desktop.nix index 941b733..fe9d8e8 100644 --- a/hosts/configuration_desktop.nix +++ b/hosts/configuration_desktop.nix @@ -143,15 +143,6 @@ # com.obsproject.Studio # com.parsecgaming.parsec # com.usebottles.bottles - snapper.configs = { - home = { - subvolume = "/home"; - extraConfig = '' - TIMELINE_CREATE=yes - TIMELINE_CLEANUP=yes - ''; - }; - }; gvfs.enable = true; }; diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index 2c4a37f..feff657 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -24,6 +24,29 @@ boot.tmpOnTmpfs = true; zramSwap.enable = true; + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" + ]; + }; + + services.snapper.configs = { + home = { + subvolume = "/home"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + }; + fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; diff --git a/hosts/laptop/hardware-configuration.nix b/hosts/laptop/hardware-configuration.nix index 2c08ff1..cbea40f 100644 --- a/hosts/laptop/hardware-configuration.nix +++ b/hosts/laptop/hardware-configuration.nix @@ -33,6 +33,29 @@ }; }; + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" + ]; + }; + + services.snapper.configs = { + home = { + subvolume = "/home"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + }; + fileSystems."/" = { device = "/dev/mapper/root"; fsType = "btrfs"; diff --git a/hosts/nas/hardware-configuration.nix b/hosts/nas/hardware-configuration.nix index 738ab44..77b336d 100644 --- a/hosts/nas/hardware-configuration.nix +++ b/hosts/nas/hardware-configuration.nix @@ -38,6 +38,115 @@ boot.tmpOnTmpfs = true; zramSwap.enable = true; + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" + "/mnt/Pluto" + "/mnt/Mars" + ]; + }; + + services.snapper.configs = { + home = { + subvolume = "/home"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + mars_home = { + subvolume = "/mnt/Mars/Home"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_backups = { + subvolume = "/mnt/Pluto/Backups"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="3" + TIMELINE_LIMIT_DAILY="3" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_games = { + subvolume = "/mnt/Pluto/Games"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_it = { + subvolume = "/mnt/Pluto/IT"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5"hm + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_media = { + subvolume = "/mnt/Pluto/Media"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_pictures = { + subvolume = "/mnt/Pluto/Pictures"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + pluto_rest = { + subvolume = "/mnt/Pluto/Rest"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + }; + fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; @@ -74,12 +183,60 @@ options = [ "compress=zstd,space_cache=v2,noatime,subvol=@" ]; }; + fileSystems."/mnt/Pluto/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots" ]; + }; + + fileSystems."/mnt/Pluto/Backups/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Backups" ]; + }; + + fileSystems."/mnt/Pluto/Games/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Games" ]; + }; + + fileSystems."/mnt/Pluto/IT/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/IT" ]; + }; + + fileSystems."/mnt/Pluto/Media/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Media" ]; + }; + + fileSystems."/mnt/Pluto/Pictures/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Pictures" ]; + }; + + fileSystems."/mnt/Pluto/Rest/.snapshots" = + { device = "/dev/disk/by-label/NAS-RAID"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,noatime,subvol=@snapshots/Rest" ]; + }; + fileSystems."/mnt/Mars" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs"; options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@nas,discard=async" ]; }; + fileSystems."/mnt/Mars/Home/.snapshots" = + { device = "/dev/disk/by-label/NIXROOT"; + fsType = "btrfs"; + options = [ "compress=zstd,space_cache=v2,ssd,noatime,subvol=@snapshots/mars/Home,discard=async" ]; + }; + fileSystems."/boot" = { device = "/dev/disk/by-label/NIXBOOT"; fsType = "vfat"; @@ -95,6 +252,11 @@ options = [ "bind" ]; }; + fileSystems."/export/Nix" = + { device = "/nix"; + options = [ "bind" ]; + }; + swapDevices = [ ]; diff --git a/hosts/server/hardware-configuration.nix b/hosts/server/hardware-configuration.nix index c814bf6..b3a52d4 100644 --- a/hosts/server/hardware-configuration.nix +++ b/hosts/server/hardware-configuration.nix @@ -24,6 +24,29 @@ boot.tmpOnTmpfs = true; zramSwap.enable = true; + services.btrfs.autoScrub = { + enable = true; + interval = "monthly"; + fileSystems = [ + "/" + ]; + }; + + services.snapper.configs = { + home = { + subvolume = "/home"; + extraConfig = '' + TIMELINE_CREATE=yes + TIMELINE_CLEANUP=yes + TIMELINE_LIMIT_HOURLY="5" + TIMELINE_LIMIT_DAILY="5" + TIMELINE_LIMIT_WEEKLY="2" + TIMELINE_LIMIT_MONTHLY="2" + TIMELINE_LIMIT_YEARLY="0" + ''; + }; + }; + fileSystems."/" = { device = "/dev/disk/by-label/NIXROOT"; fsType = "btrfs";