disko
disko copied to clipboard
ZFS uses incorrect disk in interactive VM when using multiple disks.
I'm using following configuration & vmWithDisko:
disko.devices = {
disk = {
disk-1 = {
imageSize = "512110190592";
type = "disk";
device = "/dev/disk/by-id/nvme-eui...";
content = {
type = "gpt";
partitions = {
esp = {
priority = 1;
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot-1";
};
};
special = {
priority = 2;
size = "320G";
content = {
type = "zfs";
pool = "zroot";
};
};
swap = {
priority = 3;
size = "8G";
content = {
type = "swap";
discardPolicy = "both";
};
};
cache = {
priority = 4;
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
disk-2 = {
imageSize = "512110190592";
type = "disk";
device = "/dev/disk/by-id/nvme-eui....";
content = {
type = "gpt";
partitions = {
esp = {
priority = 1;
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot-2";
};
};
special = {
priority = 2;
size = "320G";
content = {
type = "zfs";
pool = "zroot";
};
};
swap = {
priority = 3;
size = "8G";
content = {
type = "swap";
discardPolicy = "both";
};
};
cache = {
priority = 4;
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
disk-3 = {
imageSize = "16000900661248";
type = "disk";
device = "/dev/disk/by-id/wwn-...";
content = {
type = "gpt";
partitions = {
esp = {
priority = 1;
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot-3";
};
};
zfs = {
priority = 2;
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
disk-4 = {
imageSize = "16000900661248";
type = "disk";
device = "/dev/disk/by-id/wwn-...";
content = {
type = "gpt";
partitions = {
esp = {
priority = 1;
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot-4";
};
};
zfs = {
priority = 2;
size = "14880G";
content = {
type = "zfs";
pool = "zroot";
};
};
};
};
};
};
zpool = {
zroot = {
options.ashift = "12";
mode = {
topology = {
type = "topology";
vdev = [
{
mode = "mirror";
members = [
"/dev/disk/by-partlabel/disk-disk-3-zfs"
"/dev/disk/by-partlabel/disk-disk-4-zfs"
];
}
];
special = {
mode = "mirror";
members = [
"/dev/disk/by-partlabel/disk-disk-1-special"
"/dev/disk/by-partlabel/disk-disk-2-special"
];
};
cache = [
"/dev/disk/by-partlabel/disk-disk-1-cache"
"/dev/disk/by-partlabel/disk-disk-2-cache"
];
};
};
};
};
};
Sometimes it works, but mostly hangs on importing ZFS pool.
It seems that is due to this line: https://github.com/nix-community/disko/blob/master/lib/interactive-vm.nix#L65
And can be worked around via:
boot.zfs.devNodes = lib.mkForce "/dev/disk/by-id";
Looks like your observation is contracting with this comment?
Yes, /dev/disk/by-id works for me, maybe it will not work in some circumstances, but I did not encounter them.
https://github.com/nix-community/nixos-anywhere/issues/156 is this issue related?
https://discourse.nixos.org/t/cannot-import-zfs-pool-at-boot/4805
The provided solution also worked for me!
boot.zfs.devNodes = "/dev/disk/by-path";