diff options
Diffstat (limited to 'nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix')
-rw-r--r-- | nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix b/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix index f64493e1a3c..c0ff28039b1 100644 --- a/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix +++ b/nixpkgs/nixos/modules/tasks/filesystems/btrfs.nix @@ -128,7 +128,10 @@ in Nice = 19; IOSchedulingClass = "idle"; ExecStart = "${pkgs.btrfs-progs}/bin/btrfs scrub start -B ${fs}"; - ExecStop = "${pkgs.btrfs-progs}/bin/btrfs scrub cancel ${fs}"; + # if the service is stopped before scrub end, cancel it + ExecStop = pkgs.writeShellScript "btrfs-scrub-maybe-cancel" '' + (${pkgs.btrfs-progs}/bin/btrfs scrub status ${fs} | ${pkgs.gnugrep}/bin/grep finished) || ${pkgs.btrfs-progs}/bin/btrfs scrub cancel ${fs} + ''; }; }; in listToAttrs (map scrubService cfgScrub.fileSystems); |