From b320fcd543c29f6a35701959ee2bfe5299775a25 Mon Sep 17 00:00:00 2001 From: oddlama Date: Sat, 29 Apr 2023 19:42:44 +0200 Subject: [PATCH] zpool: don't mount created datasets directly; and fix encrypted import This is necessary to support non-legacy mounts, since the creation order and the required mounting order can be different in order to not shadow any datasets. Adding -l to the import statement is necessary to allow encrypted datasets to be mounted later using disko-mount. --- types/zfs_fs.nix | 5 ++++- types/zpool.nix | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/types/zfs_fs.nix b/types/zfs_fs.nix index a9ad950..1a4813b 100644 --- a/types/zfs_fs.nix +++ b/types/zfs_fs.nix @@ -38,8 +38,11 @@ }; _create = diskoLib.mkCreateOption { inherit config options; + # -u prevents mounting newly created datasets, which is + # important to prevent accidental shadowing of mount points + # since (create order != mount order) default = { zpool }: '' - zfs create ${zpool}/${config.name} \ + zfs create -u ${zpool}/${config.name} \ ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} ''; }; diff --git a/types/zpool.nix b/types/zpool.nix index b415bd5..a8f9ccb 100644 --- a/types/zpool.nix +++ b/types/zpool.nix @@ -82,7 +82,7 @@ { dev = '' zpool list '${config.name}' >/dev/null 2>/dev/null || \ - zpool import -R ${config.mountRoot} '${config.name}' + zpool import -l -R ${config.mountRoot} '${config.name}' ${lib.concatMapStrings (x: x.dev or "") (lib.attrValues datasetMounts)} ''; fs = (datasetMounts.fs or {}) // lib.optionalAttrs (config.mountpoint != null) {