mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
Merge pull request #474 from Enzime/fix/zfs-root-dataset
zpool: fix default dataset getting shadowed
This commit is contained in:
commit
b4104fcaea
3 changed files with 108 additions and 0 deletions
79
example/non-root-zfs.nix
Normal file
79
example/non-root-zfs.nix
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
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";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
y = {
|
||||
type = "disk";
|
||||
device = "/dev/sdy";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
zfs = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "storage";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
z = {
|
||||
type = "disk";
|
||||
device = "/dev/sdz";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
zfs = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "zfs";
|
||||
pool = "storage";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
zpool = {
|
||||
storage = {
|
||||
type = "zpool";
|
||||
mode = "mirror";
|
||||
mountpoint = "/storage";
|
||||
|
||||
datasets = {
|
||||
dataset = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/storage/dataset";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -67,6 +67,9 @@
|
|||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||
"''${zfs_devices[@]}"
|
||||
${lib.optionalString ((config.rootFsOptions.mountpoint or "") != "none") ''
|
||||
zfs unmount ${config.name}
|
||||
''}
|
||||
${lib.concatMapStrings (dataset: dataset._create) (lib.attrValues config.datasets)}
|
||||
'';
|
||||
};
|
||||
|
|
26
tests/non-root-zfs.nix
Normal file
26
tests/non-root-zfs.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "non-root-zfs";
|
||||
disko-config = ../example/non-root-zfs.nix;
|
||||
extraInstallerConfig.networking.hostId = "8425e349";
|
||||
extraSystemConfig.networking.hostId = "8425e349";
|
||||
postDisko = ''
|
||||
machine.succeed("mountpoint /mnt/storage")
|
||||
machine.succeed("mountpoint /mnt/storage/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
|
||||
print(f"/mnt/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/mnt/storage is not ZFS"
|
||||
'';
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /storage")
|
||||
machine.succeed("mountpoint /storage/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
|
||||
print(f"/mnt/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage is not ZFS"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue