I have two devices setup as RAID1 which I assume data (and metadata) will always mirror on both.

$ sudo btrfs filesystem show 
Label: none  uuid: eaf30e64-0a90-447f-b53d-1598fe46a8a9
    Total devices 2 FS bytes used 751.55GiB
    devid    1 size 931.51GiB used 763.03GiB path /dev/sda
    devid    2 size 931.51GiB used 763.03GiB path /dev/sdb

$ sudo btrfs filesystem df /
Data, RAID1: total=758.00GiB, used=748.13GiB
System, RAID1: total=32.00MiB, used=144.00KiB
Metadata, RAID1: total=5.00GiB, used=3.42GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

Do I need to run btrfs balance on this setup?

If yes, how often?


While what Emmanuel Rosa quoted from the Wiki is technically correct (and he's also right by the way, check the wiki, and if you're feeling really adventurous, the list archives for the linux-btrfs@vger.kernel.org mailing list, there's lots of useful info there), there are two things which I would like to point out which are (unfortunately) a bit big to fit in a comment:

  1. That particular FAQ entry on the wiki is slightly outdated. Current mainline Linux kernels (4.14 as of this answer) have some degree of automated cleanup, though I'm not sure which distros have new enough kernels to provide that.
  2. If you have a high amount of churn on your filesystem (lots of files being created, deleted, and/or copied around on a regular basis), then it can be beneficial to do a small partial balances on a semi-regular basis. For example, I have the following run on most of my systems daily:

    btrfs balance start -dusage=50 -dlimit=4 -musage=50 -mlimit=16

    This will balance the first four data chunks on the disk that are no more than 50% full, and the first sixteen metadata chunks on the disk that are no more than 50% full. This translates to moving at most just over 4GB of data around, which completes pretty fast, and helps keep the regular churn on my systems from negatively impacting the filesystem all that much.

  • Where did you get the idea to run that daily and how do you know it is beneficial? – endolith Jul 16 '19 at 15:39

Quoted verbatim from the BTRFS FAQ:

Do I need to run a balance regularly?

In general usage, no. A full unfiltered balance typically takes a long time, and will rewrite huge amounts of data unnecessarily. You may wish to run a balance on metadata only (see Balance_Filters) if you find you have very large amounts of metadata space allocated but unused, but this should be a last resort. At some point, this kind of clean-up will be made an automatic background process. - https://btrfs.wiki.kernel.org/index.php/FAQ#Do_I_need_to_run_a_balance_regularly.3F

TIP: Anyone using BTRFS, or planning to use BTRFS should read the BTRFS Wiki first. It's absolutely loaded with insight that will save you grief later. Such as, how to properly layout your filesystem in order to best leverage subvolumes, the performance issues with random-writes, how "RAID" works, etc. It's a treasure-trove of information that's definitely worth the few evenings worth of reading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.