mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 22:50:49 +00:00
zfs: Force sync on shutdown (#16903)
This commit is contained in:
parent
e54ec2f907
commit
9a8e0d1c2e
|
@ -270,7 +270,23 @@ in
|
|||
("$zpool_cmd" list "${pool}" >/dev/null) || "$zpool_cmd" import -d ${cfgZfs.devNodes} -N ${optionalString cfgZfs.forceImportAll "-f"} "${pool}"
|
||||
'';
|
||||
};
|
||||
in listToAttrs (map createImportService dataPools) // {
|
||||
|
||||
# This forces a sync of any ZFS pools prior to poweroff, even if they're set
|
||||
# to sync=disabled.
|
||||
createSyncService = pool:
|
||||
nameValuePair "zfs-sync-${pool}" {
|
||||
description = "Sync ZFS pool \"${pool}\"";
|
||||
wantedBy = [ "shutdown.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
${zfsUserPkg}/sbin/zfs set nixos:shutdown-time="$(date)" "${pool}"
|
||||
'';
|
||||
};
|
||||
|
||||
in listToAttrs (map createImportService dataPools ++ map createSyncService allPools) // {
|
||||
"zfs-mount" = { after = [ "systemd-modules-load.service" ]; };
|
||||
"zfs-share" = { after = [ "systemd-modules-load.service" ]; };
|
||||
"zed" = { after = [ "systemd-modules-load.service" ]; };
|
||||
|
|
Loading…
Reference in a new issue