From bb3836768594ca8faa1b8349a4c7c2f7224457f4 Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Sun, 31 Mar 2024 22:04:31 +0200 Subject: [PATCH] Add zfs cluster --- hosts/franz/default.nix | 15 +++-- hosts/franz/disko/zfs.nix | 120 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 hosts/franz/disko/zfs.nix diff --git a/hosts/franz/default.nix b/hosts/franz/default.nix index 3c8db81..89945c7 100644 --- a/hosts/franz/default.nix +++ b/hosts/franz/default.nix @@ -14,6 +14,7 @@ in { ./hardware-configuration.nix (import ../../disko/btrfs-swap.nix {device = "/dev/nvme0n1";}) + ./disko/zfs.nix ../common/global @@ -25,6 +26,16 @@ in { ./arion ]; + # Enable ZFS + boot.supportedFilesystems = ["zfs"]; + networking.hostId = "f014fc43"; + + systemd.enableEmergencyMode = false; + + # Prevent zfs from being automounted by fstab auto discovery & zfs + fileSystems."/storage/dataset".options = ["noauto"]; + fileSystems."/storage".options = ["noauto"]; + users.mutableUsers = true; users.users.${vars.user} = { password = "changeme"; @@ -38,10 +49,6 @@ in { }; security.pam.enableSSHAgentAuth = true; - fileSystems."/drives/hdd" = { - device = "/dev/disk/by-uuid/7d5eaff7-c17d-4fac-b7d7-7aa3c35b9a29"; - }; - nixpkgs = { overlays = [ outputs.overlays.additions diff --git a/hosts/franz/disko/zfs.nix b/hosts/franz/disko/zfs.nix new file mode 100644 index 0000000..056fb7f --- /dev/null +++ b/hosts/franz/disko/zfs.nix @@ -0,0 +1,120 @@ +{ + disko.devices = { + disk = { + a = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + b = { + type = "disk"; + device = "/dev/sdb"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + c = { + type = "disk"; + device = "/dev/sdc"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + d = { + type = "disk"; + device = "/dev/sdd"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + e = { + type = "disk"; + device = "/dev/sde"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + f = { + type = "disk"; + device = "/dev/sdf"; + content = { + type = "gpt"; + partitions = { + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "storage"; + }; + }; + }; + }; + }; + }; + zpool = { + storage = { + type = "zpool"; + mode = "raidz2"; + mountpoint = "/storage"; + datasets = { + dataset = { + type = "zfs_fs"; + mountpoint = "/storage/dataset"; + options = { + encryption = "on"; + keyformat = "hex"; + keylocation = "file:///home/ghoscht/.zfs/secret.key"; + }; + }; + }; + }; + }; + }; +}