zpool: only unmount when root dataset is mounted

Fixes #486
This commit is contained in:
Michael Hoang authored and mergify[bot] committed 2024-01-01 01:09:11 +00:00
1 parent 583bdf4fc6
commit 2791cedcba
1 file changed
+2 -2
+2 -2
View File
@@ -67,9 +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") ''
if [[ $(zfs get -H mounted ${config.name} | cut -f3) == "yes" ]]; then
zfs unmount ${config.name}
''}
fi
${lib.concatMapStrings (dataset: dataset._create) (lib.attrValues config.datasets)}
'';
};