aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/tasks/filesystems
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/tasks/filesystems')
-rw-r--r--nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix7
-rw-r--r--nixpkgs/nixos/modules/tasks/filesystems/zfs.nix6
2 files changed, 11 insertions, 2 deletions
diff --git a/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix b/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix
index 48be18c7102..f64493e1a3c 100644
--- a/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix
+++ b/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix
@@ -118,12 +118,17 @@ in
fs' = utils.escapeSystemdPath fs;
in nameValuePair "btrfs-scrub-${fs'}" {
description = "btrfs scrub on ${fs}";
+ # scrub prevents suspend2ram or proper shutdown
+ conflicts = [ "shutdown.target" "sleep.target" ];
+ before = [ "shutdown.target" "sleep.target" ];
serviceConfig = {
- Type = "oneshot";
+ # simple and not oneshot, otherwise ExecStop is not used
+ Type = "simple";
Nice = 19;
IOSchedulingClass = "idle";
ExecStart = "${pkgs.btrfs-progs}/bin/btrfs scrub start -B ${fs}";
+ ExecStop = "${pkgs.btrfs-progs}/bin/btrfs scrub cancel ${fs}";
};
};
in listToAttrs (map scrubService cfgScrub.fileSystems);
diff --git a/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix b/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
index d14ba98ec48..09c7e074e12 100644
--- a/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
@@ -623,7 +623,11 @@ in
after = [ "zfs-import.target" ];
path = [ packages.zfsUser ];
startAt = cfgTrim.interval;
- serviceConfig.ExecStart = "${pkgs.runtimeShell} -c 'zpool list -H -o name | xargs --no-run-if-empty -n1 zpool trim'";
+ # By default we ignore errors returned by the trim command, in case:
+ # - HDDs are mixed with SSDs
+ # - There is a SSDs in a pool that is currently trimmed.
+ # - There are only HDDs and we would set the system in a degraded state
+ serviceConfig.ExecStart = ''${pkgs.runtimeShell} -c 'for pool in $(zpool list -H -o name); do zpool trim $pool; done || true' '';
};
})
];