Skip to content

Commit 7ea6edd

Browse files
committed
zfs-with-vdevs: add an example for using absolute device paths
This is the only way to assign devices rather than fixed gpt partitions. Without reading the code it's not very obvious how disko actually assigns devices to zpools.
1 parent 2ee76c8 commit 7ea6edd

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

example/zfs-with-vdevs.nix

+6-3
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,14 @@
244244
type = "topology";
245245
vdev = [
246246
{
247-
mode = "mirror";
248-
members = [ "data1" "data2" ];
247+
# This syntax expects a disk called 'data3' with a gpt partition called 'zfs'.
248+
members = [ "data1" ];
249+
# It's also possible to use the full path of the device or partition
250+
# members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
249251
}
250252
{
251-
members = [ "data3" ];
253+
mode = "mirror";
254+
members = [ "data2" "data3" ];
252255
}
253256
];
254257
spare = [ "spare" ];

lib/types/zpool.nix

+38
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,44 @@ in
2525
};
2626
mode = lib.mkOption {
2727
default = "";
28+
example = {
29+
mode = {
30+
topology = {
31+
type = "topology";
32+
vdev = [
33+
{
34+
# Members can be either specified by a full path or by a disk name
35+
# This is example uses the full path
36+
members = [ "/dev/disk/by-id/wwn-0x5000c500af8b2a14" ];
37+
}
38+
];
39+
log = [
40+
{
41+
# Example using gpt partition labels
42+
# This expects an disk called `ssd` with a gpt partition called `zfs`
43+
# disko.devices.disk.ssd = {
44+
# type = "disk";
45+
# device = "/dev/nvme0n1";
46+
# content = {
47+
# type = "gpt";
48+
# partitions = {
49+
# zfs = {
50+
# size = "100%";
51+
# content = {
52+
# type = "zfs";
53+
# # use your own pool name here
54+
# pool = "zroot";
55+
# };
56+
# };
57+
# };
58+
# };
59+
# };
60+
members = [ "ssd" ];
61+
}
62+
];
63+
};
64+
};
65+
};
2866
type = (lib.types.oneOf [
2967
(lib.types.enum modeOptions)
3068
(lib.types.attrsOf (diskoLib.subType {

tests/zfs-with-vdevs.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ diskoLib.testLib.makeDiskoTest {
5757
vdev = ""
5858
actual.sort()
5959
expected=sorted([
60-
'zroot /dev/disk/by-partlabel/disk-data3-zfs',
61-
'zroot mirror /dev/disk/by-partlabel/disk-data1-zfs',
60+
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
6261
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
62+
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
6363
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
6464
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
6565
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',

0 commit comments

Comments
 (0)