Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapper gives me problems #10

Open
Nosirus opened this issue Dec 31, 2023 · 1 comment
Open

Snapper gives me problems #10

Nosirus opened this issue Dec 31, 2023 · 1 comment

Comments

@Nosirus
Copy link

Nosirus commented Dec 31, 2023

Hello,
I used your storage.nix configuration which I find very well done.
snapraid, mergerfs no problem.
on the other hand snapper blocks me I get the error

The config 'root' does not exist. Likely snapper is not configured.
See 'man snapper' for further instructions.

snapper list-configs

Config | Subvolume
-------+----------
d01    | /mnt/d01 
d02    | /mnt/d02 
d03    | /mnt/d03 
d04    | /mnt/d04 
d05    | /mnt/d05 
d06    | /mnt/d06 
d07    | /mnt/d07 
d08    | /mnt/d08 
d09    | /mnt/d09 
No permissions.

snapraid-btrfs sync
.snapraid-btrfs-wrapped: No snapper configs found for any data drives in /etc/snapraid.conf

here is my storage.nix

{ config, lib, pkgs, modulesPath, ... }: let

  disks = [
    {
      type = "parity";
      name = "p01";
      uuid = "2ffcf359-295a-4bf2-8847-c3e73aa46b81";
    }
    {
      type = "parity";
      name = "p02";
      uuid = "aad7901c-6e7c-4d8c-a9fa-dba8646e24bf";
    }
    {
      type = "data";
      name = "d01";
      uuid = "d96b4454-c0f1-499a-abf8-38f51fc4f3e5";
    }
    {
      type = "data";
      name = "d02";
      uuid = "c5458c1f-7dee-4a67-9eab-5da6ebc4ec24";
    }
    {
      type = "data";
      name = "d03";
      uuid = "16d2d864-b2b1-4ad4-8572-b60dabf3914a";
    }
    {
      type = "data";
      name = "d04";
      uuid = "98790647-5b37-4bb7-a6e4-a3556c2f88f4";
    }
    {
      type = "data";
      name = "d05";
      uuid = "20bad799-6a9f-46b3-885a-b85d87f75fec";
    }
    {
      type = "data";
      name = "d06";
      uuid = "43cbfccd-c338-488a-b13b-3576e5d999ed";
    }
    {
      type = "data";
      name = "d07";
      uuid = "7c9bd3bc-81ba-4575-8355-2cd75bb80726";
    }
    {
      type = "data";
      name = "d08";
      uuid = "09fb4679-ce83-438d-83a6-ce85e49f049f";
    }
    {
      type = "data";
      name = "d09";
      uuid = "38b57001-05a3-46ca-855a-1d2a65ea147d";
    }
  ];
  parityDisks = builtins.filter (d: d.type == "parity") disks;
  dataDisks = builtins.filter (d: d.type == "data") disks;
  parityFs = builtins.listToAttrs (builtins.map (d: {
      name = "/mnt/${d.name}";
      value = {
        device = "/dev/disk/by-uuid/${d.uuid}";
        fsType = "btrfs";
        options = [ "noatime" "nofail" ];
       };
    })
    parityDisks);
  dataFs = builtins.listToAttrs (builtins.concatMap (d: [
      {
        name = "/mnt/root/${d.name}";
        value = {
          device = "/dev/disk/by-uuid/${d.uuid}";
          fsType = "btrfs";
        };
      }
      {
        name = "/mnt/${d.name}";
        value = {
          device = "/dev/disk/by-uuid/${d.uuid}";
          fsType = "btrfs";
          options = ["subvol=data" "noatime" "nofail" "compress=zstd" ];
         };
      }
      {
        name = "/mnt/${d.name}/.snapshots";
        value = {
          device = "/dev/disk/by-uuid/${d.uuid}";
          fsType = "btrfs";
          options = ["subvol=.snapshots" "noatime" "nofail" "compress=zstd" ];
        };
      }
      {
        name = "/mnt/snapraid-content/${d.name}";
        value = {
          device = "/dev/disk/by-uuid/${d.uuid}";
          fsType = "btrfs";
          options = ["subvol=content" "noatime" "nofail" "compress=zstd" ];

        };
      }
    ])
    dataDisks);
    
  snapraidDataDisks = builtins.listToAttrs (lib.lists.imap0 (i: d: {
      name = "d${toString i}";
      value = "/mnt/${d.name}";
    })
    dataDisks);
    
  contentFiles =
    [
      "/persist/system/snapraid-content"
    ]
    ++ builtins.map (d: "/mnt/snapraid-content/${d.name}/snapraid.content") dataDisks;
  parityFiles = builtins.map (p: "/mnt/${p.name}/snapraid.parity") parityDisks;
  snapperConfigs = builtins.listToAttrs (builtins.map (d: {
      name = "${d.name}";
      value = {
        SUBVOLUME = "/mnt/${d.name}";
        ALLOW_GROUPS = ["wheel"];
        SYNC_ACL = true;
      };
    })
    dataDisks);
in {
  imports = [
    # ./network-share.nix
  ];

  environment.systemPackages = with pkgs; [
    mergerfs
    snapraid-btrfs
    snapraid-btrfs-runner
  ];

  fileSystems =
    {
      "/mnt/storage" = {
        device = lib.strings.concatMapStringsSep ":" (d: "/mnt/${d.name}") dataDisks;
        fsType = "fuse.mergerfs";
        options = [
          "defaults"
          "nofail"
          "nonempty"
          "allow_other"
          "use_ino"
          "cache.files=partial"
          "category.create=mfs"
          "moveonenospc=true"
          "dropcacheonclose=true"
          "minfreespace=100G"
          "fsname=mergerfs"
        ];
      };
    }
    // parityFs
    // dataFs;

  services.snapraid = {
    inherit contentFiles parityFiles;
    enable = true;
    sync.interval = ""; #sync.interval = "05:00";
    scrub.interval = ""; #scrub.interval = "Mon *-*-* 07:00:00";
    dataDisks = snapraidDataDisks;
    extraConfig = ''
      nohidden
      autosave 500
    '';
    exclude = [
      "*.unrecoverable"
      "/tmp/"
      "/lost+found/"
      "Téléchargements/"
      "/.snapshots/"
    ];
  };

  services.snapper = {
    configs = snapperConfigs;
  };

  # systemd.services.snapraid-btrfs-sync = {
  #   description = "Run the snapraid-btrfs sync with the runner";
  #   startAt = "01:00";
  #   serviceConfig = {
  #     Type = "oneshot";
  #     ExecStart = "${pkgs.snapraid-btrfs-runner}/bin/snapraid-btrfs-runner";
  #     Nice = 19;
  #     IOSchedulingPriority = 7;
  #     CPUSchedulingPolicy = "batch";

  #     LockPersonality = true;
  #     MemoryDenyWriteExecute = true;
  #     NoNewPrivileges = true;
  #     PrivateTmp = true;
  #     ProtectClock = true;
  #     ProtectControlGroups = true;
  #     ProtectHostname = true;
  #     ProtectKernelLogs = true;
  #     ProtectKernelModules = true;
  #     ProtectKernelTunables = true;
  #     RestrictAddressFamilies = "AF_UNIX";
  #     RestrictNamespaces = true;
  #     RestrictRealtime = true;
  #     RestrictSUIDSGID = true;
  #     SystemCallArchitectures = "native";
  #     SystemCallFilter = "@system-service";
  #     SystemCallErrorNumber = "EPERM";
  #     CapabilityBoundingSet = "";
  #     ProtectSystem = "strict";
  #     ProtectHome = "read-only";
  #     ReadOnlyPaths = ["/etc/snapraid.conf" "/etc/snapper"];
  #     ReadWritePaths =
  #       # sync requires access to directories containing content files
  #       # to remove them if they are stale
  #       let
  #         contentDirs = builtins.map builtins.dirOf contentFiles;
  #       in
  #         lib.unique (
  #           builtins.attrValues snapraidDataDisks ++ parityFiles ++ contentDirs
  #         );
  #   };
  # };
}

snapraid.conf

data d0 /mnt/d01
data d1 /mnt/d02
data d2 /mnt/d03
data d3 /mnt/d04
data d4 /mnt/d05
data d5 /mnt/d06
data d6 /mnt/d07
data d7 /mnt/d08
data d8 /mnt/d09
parity /mnt/p01/snapraid.parity
2-parity /mnt/p02/snapraid.parity
content /persist/system/snapraid-content
content /mnt/snapraid-content/d01/snapraid.content
content /mnt/snapraid-content/d02/snapraid.content
content /mnt/snapraid-content/d03/snapraid.content
content /mnt/snapraid-content/d04/snapraid.content
content /mnt/snapraid-content/d05/snapraid.content
content /mnt/snapraid-content/d06/snapraid.content
content /mnt/snapraid-content/d07/snapraid.content
content /mnt/snapraid-content/d08/snapraid.content
content /mnt/snapraid-content/d09/snapraid.content
exclude *.unrecoverable
exclude /tmp/
exclude /lost+found/
exclude Téléchargements/
exclude /.snapshots/
nohidden
autosave 500
@kasuboski
Copy link
Owner

Does snapper list-configs return items for you?

I remember there being some weirdness with the configs where I maybe had to run the snapper create-config command, but https://github.com/kasuboski/dotfiles/blob/main/nixos/hosts/fettig/storage.nix#L80 seems like it should have set them up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants