mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
zfs: support for root dataset mountpoint and mountpoint=none
This commit is contained in:
parent
57b7c5506a
commit
722dde361c
3 changed files with 36 additions and 10 deletions
35
default.nix
35
default.nix
|
@ -256,29 +256,48 @@ let
|
|||
|
||||
mount.zfs = mount.noop;
|
||||
|
||||
mount.zpool = q: x: (
|
||||
mount.zpool = q: x:
|
||||
let
|
||||
datasets = [{
|
||||
inherit (q) name;
|
||||
type = "zfs_filesystem";
|
||||
dataset = q.name;
|
||||
mountpoint = x.mountpoint or "/${q.name}";
|
||||
options = q.rootFsOptions or { };
|
||||
}] ++ x.datasets;
|
||||
in
|
||||
recursiveUpdate
|
||||
(foldl' recursiveUpdate { } (map (mount-f (q // { pool = q.name; })) x.datasets))
|
||||
(foldl' recursiveUpdate { }
|
||||
(
|
||||
(map
|
||||
(x: mount-f
|
||||
({
|
||||
dataset = x.dataset or "${q.name}/${x.name}";
|
||||
mountpoint = x.mountpoint or "/${q.name}/${x.name}";
|
||||
} // q)
|
||||
x)
|
||||
datasets)
|
||||
)
|
||||
)
|
||||
{
|
||||
zpool.${q.device} = ''
|
||||
zpool list '${q.name}' >/dev/null 2>/dev/null || zpool import '${q.name}'
|
||||
'';
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
mount.zfs_filesystem = q: x: {
|
||||
zfs.${x.mountpoint} = ''
|
||||
if ! findmnt '${q.pool}/${x.name}' /mnt${x.mountpoint} > /dev/null 2>&1; then
|
||||
zfs.${q.mountpoint} = lib.optionalString ((x.options.mountpoint or "") != "none") ''
|
||||
if ! findmnt '${q.dataset}' /mnt${q.mountpoint} > /dev/null 2>&1; then
|
||||
mount \
|
||||
${lib.optionalString ((x.options.mountpoint or "") != "legacy") "-o zfsutil"} \
|
||||
-t zfs ${q.pool}/${x.name} /mnt${x.mountpoint} \
|
||||
-t zfs ${q.dataset} /mnt${q.mountpoint} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
mount.zfs_volume = q: x:
|
||||
mount-f { device = "/dev/zvol/${q.pool}/${x.name}"; } x.content;
|
||||
mount-f { device = "/dev/zvol/${q.dataset}"; } x.content;
|
||||
|
||||
in
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
compression = "lz4";
|
||||
"com.sun:auto-snapshot" = "false";
|
||||
};
|
||||
mountpoint = "/";
|
||||
|
||||
datasets = [
|
||||
{
|
||||
type = "zfs_filesystem";
|
||||
|
@ -23,6 +25,11 @@
|
|||
mountpoint = "/zfs_fs";
|
||||
options."com.sun:auto-snapshot" = "true";
|
||||
}
|
||||
{
|
||||
type = "zfs_filesystem";
|
||||
name = "zfs_unmounted_fs";
|
||||
options.mountpoint = "none";
|
||||
}
|
||||
{
|
||||
type = "zfs_filesystem";
|
||||
name = "zfs_legacy_fs";
|
||||
|
|
|
@ -17,9 +17,9 @@ makeDiskoTest {
|
|||
assert_property("zroot", "com.sun:auto-snapshot", "false")
|
||||
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
||||
assert_property("zroot/zfs_testvolume", "volsize", "10M")
|
||||
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
|
||||
|
||||
# FIXME: we cannot mount rootfs yet
|
||||
#machine.succeed("mountpoint /mnt");
|
||||
machine.succeed("mountpoint /mnt");
|
||||
machine.succeed("mountpoint /mnt/zfs_fs");
|
||||
machine.succeed("mountpoint /mnt/zfs_legacy_fs");
|
||||
machine.succeed("mountpoint /mnt/ext4onzfs");
|
||||
|
|
Loading…
Reference in a new issue