zpool: only unmount when root dataset is mounted

Fixes #486
This commit is contained in:
Michael Hoang 2023-12-30 09:24:50 +11:00 committed by mergify[bot]
parent 583bdf4fc6
commit 2791cedcba

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)}
'';
};