mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-06 01:38:06 +00:00
[FileSystems/Btrfs] improve performance + fix autoScrub conf
This commit is contained in:
parent
e496065dc6
commit
97335ca0de
1 changed files with 23 additions and 8 deletions
|
|
@ -9,11 +9,18 @@ let
|
||||||
in {
|
in {
|
||||||
options.aviallon.filesystems.btrfs = {
|
options.aviallon.filesystems.btrfs = {
|
||||||
enable = mkEnableOption "BTRFS support";
|
enable = mkEnableOption "BTRFS support";
|
||||||
autoScrub = mkOption {
|
autoScrub = {
|
||||||
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Wether to enable automatic scrubbing";
|
description = "Wether to enable automatic scrubbing";
|
||||||
};
|
};
|
||||||
|
paths = mkOption {
|
||||||
|
type = with types; nonEmptyListOf path;
|
||||||
|
default = btrfsPaths;
|
||||||
|
description = "What paths to scrub. Must be a btrfs mount point.";
|
||||||
|
};
|
||||||
|
};
|
||||||
autoDedup = {
|
autoDedup = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
|
|
@ -43,29 +50,37 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.btrfs.autoScrub = {
|
services.btrfs.autoScrub = {
|
||||||
enable = true;
|
enable = cfg.autoScrub.enable;
|
||||||
fileSystems = [ "/" ];
|
fileSystems = cfg.autoScrub.paths;
|
||||||
};
|
};
|
||||||
systemd.services.duperemove = {
|
systemd.services.duperemove = {
|
||||||
script = ''
|
script = ''
|
||||||
mkdir -p $DATA_DIR
|
mkdir -p $DATA_DIR
|
||||||
exec ${pkgs.duperemove}/bin/duperemove --io-threads=${toString cfg.autoDedup.ioThreads} --cpu-threads=${toString cfg.autoDedup.cpuThreads} -h --dedupe-options=fiemap,same --hashfile=$DATA_DIR/hashes.db -v -Ard "$@"
|
exec ${pkgs.duperemove}/bin/duperemove \
|
||||||
|
--io-threads=${toString cfg.autoDedup.ioThreads} --cpu-threads=${toString cfg.autoDedup.cpuThreads} \
|
||||||
|
--dedupe-options=fiemap,same \
|
||||||
|
--hashfile=$DATA_DIR/hashes.db -h -v -Ard "$@"
|
||||||
'';
|
'';
|
||||||
scriptArgs = concatStringsSep " " cfg.autoDedup.paths;
|
scriptArgs = concatStringsSep " " cfg.autoDedup.paths;
|
||||||
# %S : state
|
# %S : state
|
||||||
environment = {
|
environment = {
|
||||||
DATA_DIR = "%S/duperemove";
|
DATA_DIR = "%S/duperemove";
|
||||||
};
|
};
|
||||||
|
unitConfig = {
|
||||||
|
ConditionCPUPressure = "50%";
|
||||||
|
ConditionIOPressure = "30%";
|
||||||
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
CPUQuota = "50%";
|
CPUQuota = "50%";
|
||||||
|
CPUWeight = 1;
|
||||||
Nice = 19;
|
Nice = 19;
|
||||||
MemoryAccounting = true;
|
MemoryAccounting = true;
|
||||||
MemoryHigh = "33%";
|
MemoryHigh = "33%";
|
||||||
MemoryMax = "50%";
|
MemoryMax = "50%";
|
||||||
IOWeight = 10;
|
IOWeight = 10;
|
||||||
|
ManagedOOMMemoryPressure = "kill";
|
||||||
};
|
};
|
||||||
requires = [ "local-fs.target" ];
|
requires = [ "local-fs.target" ];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue