SUSE Support

Here When You Need Us

Configure btrfs-balance to run out of production times

This document (000021570) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 12 SP5

SUSE Linux Enterprise Server 15 


Situation

In general a btrfs balance may have an impact on the systems performance, especially on busy ones or on shared SAN Storage. 
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

SLES15 SP3 and later:
To avoid btrfs balance running during production times let's define a window of 24 hours on Sundays.

Step 1:

sles15sp62:~ # vi /etc/sysconfig/btrfsmaintenance

and 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:

vi /etc/systemd/system/btrfs-balance.timer.d/delay.conf

add

[Timer]
RandomizedDelaySec=86400

The value 86400 has been chosen in this example because a day has 86400 seconds, so the job can run on any time at Sundays. Feel free to adjust as applicable. 
We need to make the changes known to systemd:

systemctl daemon-reload

Please check if the changes have been successfull: 

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
             └─delay.conf, schedule.conf
     Active: active (waiting) since Fri 2025-02-21 09:31:49 CET; 2min 3s ago
    Trigger: Sun 2025-02-23 06:42:42 CET; 1 day 21h left
   Triggers: ● btrfs-balance.service
       Docs: man:btrfs-balance


 

As already noted SLES 12 SP5 works in a different way:

sles12sp51:~ # vi /etc/sysconfig/btrfsmaintenance

change

BTRFS_BALANCE_PERIOD="weekly"

to

BTRFS_BALANCE_PERIOD="none"

Now create a cron job for the btrfs-balance job via root user simply by running: 

{
    crontab -l
    echo "RANDOM_DELAY=1440"
    echo "0 0  * * SUN /usr/share/btrfsmaintenance/btrfs-balance.sh"
} | crontab - 

 

Note:

  • 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.
  • On SLES 15 SP[X] Make sure that the version of btrfsmaintenance does contain the fix for bcs#1233068:
    rpm -q btrfsmaintenance --changelog|grep bsc#1233068
    - Fix for SG#69163, bsc#1233068:
    

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:05-Mar-2025
    • SUSE Linux Enterprise Desktop
    • SUSE Linux Enterprise Server
    • SUSE Linux Enterprise Server for SAP Applications

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.