Configure btrfs-balance to run out of production times
This document (000021570) is provided subject to the disclaimer at the end of this document.
Situation
To avoid a balance run during production times systemd offers some very flexible tools to re-schedule the service.
SLES12 SP5 requires a different solution since the btrfsmaintenance tools utilize cron.
Resolution
To avoid btrfs balance running during production times lets
define a window of 24 hours on Sundays.
Step 1:
sles15sp62:~ # vi /etc/sysconfig/btrfsmaintenanceand change
BTRFS_BALANCE_PERIOD="weekly"to
BTRFS_BALANCE_PERIOD="Sun *-*-* 00:00:00"Due to this change, the balance now will always start on Sundays at 00:00 AM. However, it may not be desired to have all systems in a particular environment start at the same time, therefore a random delay is required for the job:
sles15sp62:~ # systemctl edit btrfs-balance.timeradd
[Timer] RandomizedDelaySec=86400The value 86400 has been chosen in this example because a day has 86400 secs, so the job can run on any time at Sundays. Feel free to adjust as applicable.
After editing and saving the file, success of the operation is shown as:
Successfully installed edited file '/etc/systemd/system/btrfs-balance.timer.d/override.conf'.As a last step, reload the changed settings:
systemctl daemon-reloadsystemd is able to show when a job will be run:
sles15sp62:~ # systemctl status btrfs-balance.timer ● btrfs-balance.timer - Balance block groups on a btrfs filesystem Loaded: loaded (/usr/lib/systemd/system/btrfs-balance.timer; enabled; preset: enabled) Drop-In: /etc/systemd/system/btrfs-balance.timer.d └─override.conf, schedule.conf Active: active (waiting) since Thu 2024-09-26 10:13:41 CEST; 2min 0s ago Trigger: Sun 2024-09-29 11:42:02 CEST; 3 days left Triggers: ● btrfs-balance.service Docs: man:btrfs-balanceAs already noted SLES12 SP5 works in a different way:
sles12sp51:~ # vi /etc/sysconfig/btrfsmaintenancechange
BTRFS_BALANCE_PERIOD="weekly"to
BTRFS_BALANCE_PERIOD="none"Now create a cron job for the btrfs-balance job
sles12sp51:~ # sudo su sles12sp51:~ # crontab -eand add
RANDOM_DELAY=660 0 0 * * SUN /usr/share/btrfsmaintenance/btrfs-balance.sh
crontab: installing new crontabNote:
The behaviour of the variable RANDOM_DELAY in crontabs is described in "man 5 crontab".
Please note: In opposite to RandomizedDelaySec, the unit of the variable RANDOM_DELAY is given in minutes.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000021570
- Creation Date: 26-Sep-2024
- Modified Date:26-Sep-2024
-
- SUSE Linux Enterprise Desktop
- SUSE Linux Enterprise Server
- SUSE Linux Enterprise Server for SAP Applications
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com