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
This commit is contained in:
Jörg Thalheim 2024-06-28 14:57:09 +02:00 committed by mergify[bot]
parent e8ef4773dd
commit 115311bc39

View file

@ -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