mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
A config like
```nix
{
vdev = [
{
mode = "mirror";
members = [ "data1" "data2" ];
}
{
members = [ "data3" ];
}
];
}
```
would result in the following command:
```shell
zpool create -f <name> mirror /dev/data1 /dev/data2 /dev/data3
```
which would result in a single vdev with a 3-way mirror, rather than a
vdev with a 2-way mirror and a second vdev with a single disk. By
reordering the vdevs to handle those with an empty mode first we
transform this into:
```shell
zpool create -f <name> /dev/data3 mirror /dev/data1 /dev/data2
```
which does have the desired outcome.
303 lines
6.4 KiB
Nix
303 lines
6.4 KiB
Nix
{
|
|
disko.devices = {
|
|
disk = {
|
|
data1 = {
|
|
type = "disk";
|
|
device = "/dev/vda";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
size = "64M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
mountOptions = [ "umask=0077" ];
|
|
};
|
|
};
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
data2 = {
|
|
type = "disk";
|
|
device = "/dev/vdb";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
data3 = {
|
|
type = "disk";
|
|
device = "/dev/vdc";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
spare = {
|
|
type = "disk";
|
|
device = "/dev/vdd";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
log1 = {
|
|
type = "disk";
|
|
device = "/dev/vde";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
log2 = {
|
|
type = "disk";
|
|
device = "/dev/vdf";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
log3 = {
|
|
type = "disk";
|
|
device = "/dev/vdg";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
dedup1 = {
|
|
type = "disk";
|
|
device = "/dev/vdh";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
dedup2 = {
|
|
type = "disk";
|
|
device = "/dev/vdi";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
dedup3 = {
|
|
type = "disk";
|
|
device = "/dev/vdj";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
special1 = {
|
|
type = "disk";
|
|
device = "/dev/vdk";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
special2 = {
|
|
type = "disk";
|
|
device = "/dev/vdl";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
special3 = {
|
|
type = "disk";
|
|
device = "/dev/vdm";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
cache = {
|
|
type = "disk";
|
|
device = "/dev/vdn";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
zpool = {
|
|
zroot = {
|
|
type = "zpool";
|
|
mode = {
|
|
topology = {
|
|
type = "topology";
|
|
vdev = [
|
|
{
|
|
mode = "mirror";
|
|
members = [ "data1" "data2" ];
|
|
}
|
|
{
|
|
members = [ "data3" ];
|
|
}
|
|
];
|
|
spare = [ "spare" ];
|
|
log = [
|
|
{
|
|
mode = "mirror";
|
|
members = [ "log1" "log2" ];
|
|
}
|
|
{
|
|
members = [ "log3" ];
|
|
}
|
|
];
|
|
dedup = [
|
|
{
|
|
mode = "mirror";
|
|
members = [ "dedup1" "dedup2" ];
|
|
}
|
|
{
|
|
members = [ "dedup3" ];
|
|
}
|
|
];
|
|
special = [
|
|
{
|
|
mode = "mirror";
|
|
members = [ "special1" "special2" ];
|
|
}
|
|
{
|
|
members = [ "special3" ];
|
|
}
|
|
];
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|