mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
zfs_fs: support updating mountpoint properly
Use `zfs set -u` to update the `mountpoint` flag without mounting or unmounting the filesystem. This flag was added in OpenZFS 2.2.0, which was released October 2023. The previous logic would not update `mountpoint` if `config.options` was empty or only contained `mountpoint`.
This commit is contained in:
parent
88b015b9eb
commit
a9eeea3379
1 changed files with 2 additions and 15 deletions
|
@ -73,8 +73,7 @@
|
|||
"pbkdf2salt"
|
||||
"keyformat"
|
||||
];
|
||||
updateOptions = builtins.removeAttrs config.options (onetimeProperties ++ [ "mountpoint" ]);
|
||||
mountpoint = config.options.mountpoint or config.mountpoint;
|
||||
updateOptions = builtins.removeAttrs createOptions onetimeProperties;
|
||||
in
|
||||
''
|
||||
if ! zfs get type ${config._name} >/dev/null 2>&1; then
|
||||
|
@ -82,19 +81,7 @@
|
|||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
|
||||
${lib.optionalString (updateOptions != {}) ''
|
||||
else
|
||||
zfs set ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
|
||||
${lib.optionalString (mountpoint != null) ''
|
||||
if [[ "$(zfs get -H -o value mountpoint ${config._name})" != "${mountpoint}" ]]; then
|
||||
echo "Changing mountpoint to '${mountpoint}' for ${config._name}..."
|
||||
# zfs will try unmount the dataset to change the mountpoint
|
||||
# but this might fail if the dataset is in use
|
||||
if ! zfs set mountpoint=${mountpoint} ${config._name}; then
|
||||
echo "Failed to set mountpoint to '${mountpoint}' for ${config._name}." >&2
|
||||
echo "You may need to run when the pool is not mounted i.e. in a recovery system:" >&2
|
||||
echo " zfs set mountpoint=${mountpoint} ${config._name}" >&2
|
||||
fi
|
||||
fi
|
||||
''}
|
||||
zfs set -u ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
|
||||
''}
|
||||
fi
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue