summary refs log tree commit diff
diff options
context:
space:
mode:
authorSymphorien Gibol <symphorien+git@xlumurb.eu>2020-02-14 12:00:00 +0000
committerSymphorien Gibol <symphorien+git@xlumurb.eu>2020-02-14 12:00:00 +0000
commit5359d90b151f2a427becd25887512c4e4a8e6a0b (patch)
treeece9d5a8aab1b63660a4f9cdaffc543ac594942d
parent8130f3c1c2bb0e533b5e150c39911d6e61dcecc2 (diff)
downloadnixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar.gz
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar.bz2
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar.lz
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar.xz
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.tar.zst
nixpkgs-5359d90b151f2a427becd25887512c4e4a8e6a0b.zip
nixos/btrfs: make autoScrub not prevent shutdown or suspend
Fixes: #79086 #79017
-rw-r--r--nixos/modules/tasks/filesystems/btrfs.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/modules/tasks/filesystems/btrfs.nix b/nixos/modules/tasks/filesystems/btrfs.nix
index 48be18c7102..f64493e1a3c 100644
--- a/nixos/modules/tasks/filesystems/btrfs.nix
+++ b/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);