From 115311bc395f24c1b553338fec4b3aa28cbf5ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 28 Jun 2024 14:57:09 +0200 Subject: [PATCH] zfs: try to import zpool in incremental mode if the pool is not imported, zfs list will return a value. So to check that the pool does not exist, we also import it. fixes https://github.com/nix-community/disko/issues/690 --- lib/types/zpool.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/types/zpool.nix b/lib/types/zpool.nix index fd09e67..f690c98 100644 --- a/lib/types/zpool.nix +++ b/lib/types/zpool.nix @@ -62,7 +62,9 @@ inherit config options; default = '' readarray -t zfs_devices < <(cat "$disko_devices_dir"/zfs_${config.name}) - if zpool list '${config.name}'; then + # Try importing the pool without mounting anything if it exists. + # This allows us to set mounpoints. + if zpool import -N -f '${config.name}' || zpool list '${config.name}'; then echo "not creating zpool ${config.name} as a pool with that name already exists" >&2 else continue=1