add zfs example

This commit is contained in:
Jörg Thalheim 2023-08-15 13:29:21 +02:00
parent dc7a8e45a0
commit 9b4d0d6c2e
2 changed files with 107 additions and 0 deletions

105
disk-configs/zfs.nix Normal file
View File

@ -0,0 +1,105 @@
{
networking.hostId = "8425e349"; # needed for ZFS
disko.devices = {
disk = {
disk1 = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
ESP = {
size = "500M";
type = "EF00";
content = {
type = "mdraid";
name = "boot";
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
disk2 = {
type = "disk";
device = "/dev/nvme1n1";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
ESP = {
size = "500M";
type = "EF00";
content = {
type = "mdraid";
name = "boot";
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};
zpool = {
zroot = {
type = "zpool";
mode = "mirror";
rootFsOptions = {
compression = "lz4";
"com.sun:auto-snapshot" = "true";
};
rootFsOptions = {
mountpoint = "none";
};
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = null;
};
"root/nixos" = {
type = "zfs_fs";
mountpoint = "/";
};
"root/home" = {
type = "zfs_fs";
mountpoint = "/home";
};
};
};
};
mdadm = {
boot = {
type = "mdadm";
level = 1;
metadata = "1.0";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
};
};
}

View File

@ -21,11 +21,13 @@
(nixpkgs.outPath + "/nixos/modules/installer/scan/not-detected.nix") (nixpkgs.outPath + "/nixos/modules/installer/scan/not-detected.nix")
disko.nixosModules.disko disko.nixosModules.disko
./disk-configs/simple-efi.nix # choose your favorite disk layout here ./disk-configs/simple-efi.nix # choose your favorite disk layout here
#./disk-configs/zfs.nix # choose your favorite disk layout here
{ {
boot.loader.grub = { boot.loader.grub = {
efiSupport = true; efiSupport = true;
efiInstallAsRemovable = true; efiInstallAsRemovable = true;
}; };
boot.swraid.enable = true;
# Alternative to grub # Alternative to grub
#boot.loader.systemd-boot.enable = true; #boot.loader.systemd-boot.enable = true;
# when installing toggle this # when installing toggle this