Skip to content

Commit

Permalink
nixos/btrfs autoScrub: don't fail when scrub finishes successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
symphorien committed Apr 2, 2020
1 parent ae6bdcc commit 55d16d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nixos/modules/tasks/filesystems/btrfs.nix
Expand Up @@ -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);
Expand Down

0 comments on commit 55d16d5

Please sign in to comment.