-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #723 from dmadisetti/dm/zfs-extra
zfs: add ZFS "topology" features like explicit vdevs, cache, and special
- Loading branch information
Showing
4 changed files
with
306 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
disko.devices = { | ||
disk = { | ||
x = { | ||
type = "disk"; | ||
device = "/dev/sdx"; | ||
content = { | ||
type = "gpt"; | ||
partitions = { | ||
ESP = { | ||
size = "64M"; | ||
type = "EF00"; | ||
content = { | ||
type = "filesystem"; | ||
format = "vfat"; | ||
mountpoint = "/boot"; | ||
}; | ||
}; | ||
zfs = { | ||
size = "100%"; | ||
content = { | ||
type = "zfs"; | ||
pool = "zroot"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
y = { | ||
type = "disk"; | ||
device = "/dev/sdy"; | ||
content = { | ||
type = "gpt"; | ||
partitions = { | ||
zfs = { | ||
size = "100%"; | ||
content = { | ||
type = "zfs"; | ||
pool = "zroot"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
z = { | ||
type = "disk"; | ||
device = "/dev/sdz"; | ||
content = { | ||
type = "gpt"; | ||
partitions = { | ||
zfs = { | ||
size = "100%"; | ||
content = { | ||
type = "zfs"; | ||
pool = "zroot"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
cache = { | ||
type = "disk"; | ||
device = "/dev/vdc"; | ||
content = { | ||
type = "gpt"; | ||
partitions = { | ||
zfs = { | ||
size = "100%"; | ||
content = { | ||
type = "zfs"; | ||
pool = "zroot"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
zpool = { | ||
zroot = { | ||
type = "zpool"; | ||
mode = { | ||
topology = { | ||
type = "topology"; | ||
vdev = [ | ||
{ | ||
mode = "mirror"; | ||
members = [ "x" "y" ]; | ||
} | ||
]; | ||
special = { | ||
members = [ "z" ]; | ||
}; | ||
cache = [ "cache" ]; | ||
}; | ||
}; | ||
|
||
rootFsOptions = { | ||
compression = "zstd"; | ||
"com.sun:auto-snapshot" = "false"; | ||
}; | ||
mountpoint = "/"; | ||
datasets = { | ||
# See examples/zfs.nix for more comprehensive usage. | ||
zfs_fs = { | ||
type = "zfs_fs"; | ||
mountpoint = "/zfs_fs"; | ||
options."com.sun:auto-snapshot" = "true"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ pkgs ? import <nixpkgs> { } | ||
, diskoLib ? pkgs.callPackage ../lib { } | ||
}: | ||
diskoLib.testLib.makeDiskoTest { | ||
inherit pkgs; | ||
name = "zfs-with-vdevs"; | ||
disko-config = ../example/zfs-with-vdevs.nix; | ||
extraInstallerConfig.networking.hostId = "8425e349"; | ||
extraSystemConfig = { | ||
networking.hostId = "8425e349"; | ||
}; | ||
extraTestScript = '' | ||
def assert_property(ds, property, expected_value): | ||
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip() | ||
assert ( | ||
out == expected_value | ||
), f"Expected {property}={expected_value} on {ds}, got: {out}" | ||
# These fields are 0 if l2arc is disabled | ||
assert ( | ||
machine.succeed( | ||
"cat /proc/spl/kstat/zfs/arcstats" | ||
" | grep '^l2_' | tr -s ' '" | ||
" | cut -s -d ' ' -f3 | uniq" | ||
).strip() != "0" | ||
), "Excepted cache to be utilized." | ||
assert_property("zroot", "compression", "zstd") | ||
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true") | ||
assert_property("zroot/zfs_fs", "compression", "zstd") | ||
machine.succeed("mountpoint /zfs_fs"); | ||
''; | ||
} |