Skip to content

Commit

Permalink
Merge pull request #924 from nix-community/vdev
Browse files Browse the repository at this point in the history
zfs-with-vdevs: add an example for using absolute device paths
  • Loading branch information
Mic92 authored Dec 24, 2024
2 parents 2ee76c8 + 7ea6edd commit 3a4de9f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
9 changes: 6 additions & 3 deletions example/zfs-with-vdevs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,14 @@
type = "topology";
vdev = [
{
mode = "mirror";
members = [ "data1" "data2" ];
# This syntax expects a disk called 'data3' with a gpt partition called 'zfs'.
members = [ "data1" ];
# It's also possible to use the full path of the device or partition
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
}
{
members = [ "data3" ];
mode = "mirror";
members = [ "data2" "data3" ];
}
];
spare = [ "spare" ];
Expand Down
38 changes: 38 additions & 0 deletions lib/types/zpool.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,44 @@ in
};
mode = lib.mkOption {
default = "";
example = {
mode = {
topology = {
type = "topology";
vdev = [
{
# Members can be either specified by a full path or by a disk name
# This is example uses the full path
members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
}
];
log = [
{
# Example using gpt partition labels
# This expects an disk called `ssd` with a gpt partition called `zfs`
# disko.devices.disk.ssd = {
# type = "disk";
# device = "/dev/nvme0n1";
# content = {
# type = "gpt";
# partitions = {
# zfs = {
# size = "100%";
# content = {
# type = "zfs";
# # use your own pool name here
# pool = "zroot";
# };
# };
# };
# };
# };
members = [ "ssd" ];
}
];
};
};
};
type = (lib.types.oneOf [
(lib.types.enum modeOptions)
(lib.types.attrsOf (diskoLib.subType {
Expand Down
4 changes: 2 additions & 2 deletions tests/zfs-with-vdevs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ diskoLib.testLib.makeDiskoTest {
vdev = ""
actual.sort()
expected=sorted([
'zroot /dev/disk/by-partlabel/disk-data3-zfs',
'zroot mirror /dev/disk/by-partlabel/disk-data1-zfs',
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
Expand Down

0 comments on commit 3a4de9f

Please sign in to comment.