periodically balance
This commit is contained in:
@@ -97,17 +97,21 @@ in
|
||||
mail_smtpport = 465;
|
||||
enable_previews = true;
|
||||
enabledPreviewProviders = [
|
||||
"OC\\\\Preview\\\\PNG"
|
||||
"OC\\\\Preview\\\\JPEG"
|
||||
"OC\\\\Preview\\\\GIF"
|
||||
"OC\\\\Preview\\\\BMP"
|
||||
"OC\\\\Preview\\\\XBitmap"
|
||||
"OC\\\\Preview\\\\MP3"
|
||||
"OC\\\\Preview\\\\TXT"
|
||||
"OC\\\\Preview\\\\MarkDown"
|
||||
"OC\\\\Preview\\\\OpenDocument"
|
||||
"OC\\\\Preview\\\\Krita"
|
||||
"OC\\\\Preview\\\\HEIC"
|
||||
"OC\\Preview\\PNG"
|
||||
"OC\\Preview\\JPEG"
|
||||
"OC\\Preview\\GIF"
|
||||
"OC\\Preview\\BMP"
|
||||
"OC\\Preview\\XBitmap"
|
||||
"OC\\Preview\\MP3"
|
||||
"OC\\Preview\\TXT"
|
||||
"OC\\Preview\\MarkDown"
|
||||
"OC\\Preview\\OpenDocument"
|
||||
"OC\\Preview\\Krita"
|
||||
"OC\\Preview\\HEIC"
|
||||
"OC\\Preview\\Movie"
|
||||
"OC\\Preview\\MSOffice2003"
|
||||
"OC\\Preview\\MSOffice2007"
|
||||
"OC\\Preview\\MSOfficeDoc"
|
||||
];
|
||||
installed = true;
|
||||
user_oidc = {
|
||||
|
||||
@@ -230,6 +230,30 @@ in
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
btrfs-balance = {
|
||||
description = "BTRFS Balance Service";
|
||||
# This ensures the service only runs when the filesystem is mounted
|
||||
requires = [ "local-fs.target" ];
|
||||
after = [ "local-fs.target" ];
|
||||
|
||||
# The actual balance command
|
||||
script = ''
|
||||
# Start with lower usage to handle the most fragmented blocks first
|
||||
${pkgs.btrfs-progs}/bin/btrfs balance start -dusage=5 -musage=5 /mount/point
|
||||
${pkgs.btrfs-progs}/bin/btrfs balance start -dusage=10 -musage=10 /mount/point
|
||||
${pkgs.btrfs-progs}/bin/btrfs balance start -dusage=20 -musage=20 /mount/point
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
Nice = 19; # Lowest CPU priority
|
||||
IOSchedulingClass = "idle"; # Lowest I/O priority
|
||||
# Prevent multiple instances from running simultaneously
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/rm -f /var/run/btrfs-balance.stamp";
|
||||
ExecStopPost = "${pkgs.coreutils}/bin/touch /var/run/btrfs-balance.stamp";
|
||||
};
|
||||
};
|
||||
|
||||
system-update-check = {
|
||||
description = "Check for system configuration updates";
|
||||
|
||||
@@ -314,15 +338,30 @@ in
|
||||
};
|
||||
|
||||
# Create a timer to run the service periodically
|
||||
systemd.timers.system-update-check = {
|
||||
description = "Timer for system configuration updates";
|
||||
wantedBy = [ "timers.target" ];
|
||||
|
||||
# Timer configuration
|
||||
timerConfig = {
|
||||
OnCalendar = "daily"; # Check every day
|
||||
Persistent = true; # Run immediately if last run was missed
|
||||
Unit = "system-update-check.service";
|
||||
systemd.timers = {
|
||||
btrfs-balance = {
|
||||
description = "Timer for BTRFS Balance Service";
|
||||
wantedBy = [ "timers.target" ];
|
||||
|
||||
timerConfig = {
|
||||
# Run weekly on Sunday at 2am
|
||||
OnCalendar = "Sun *-*-* 02:00:00";
|
||||
# Add randomized delay to prevent multiple systems from starting at exactly the same time
|
||||
RandomizedDelaySec = "1h";
|
||||
# Ensure we don't start multiple times if the system was off
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
system-update-check = {
|
||||
description = "Timer for system configuration updates";
|
||||
wantedBy = [ "timers.target" ];
|
||||
|
||||
# Timer configuration
|
||||
timerConfig = {
|
||||
OnCalendar = "daily"; # Check every day
|
||||
Persistent = true; # Run immediately if last run was missed
|
||||
Unit = "system-update-check.service";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user