What happens when I rebalance my Btrfs file system?

What happens when I rebalance my Btrfs file system?

In this example, a rebalance could free up space on the file system. When you balance btrfs it sends everything back through the allocator and compacts the chunks. If you have two metadata chunks that are both 45%, after running a balance, you’ll have only a single metadata chunk that is 90% full.

How is space allocated in the Btrfs filesystem?

Therefore, some space needs to be freed up on it. There is a balancing feature available in Btrfs FileSystem. The balance operation effectively frees up space in the other chunks to make it available for allocation. 1. Below command shows how much space has been allocated on your filesystem:

How to check Btrfs filesystem usage and usage?

This operation is very intense and takes potentially very long. It is recommended to use the balance filters to narrow down the balanced data. Note that there should be no space between the -d and usage.

How long does it take to balance a Btrfs partition?

Here’s the caveat: The balance can take quite some time, depending on how much data is on the partition and how full the chunks are, and could possibly disrupt operations. Because of this, you’ll want to run the balance at a time when a disruption wouldn’t cause any problems.

What is the usage value for Btrfs balance?

Balances only block groups with usage under the given percentage. The value of 0 is allowed and will clean up completely unused block groups, this should not require any new work space allocated. You may want to use usage=0 in case balance is returning ENOSPC and your filesystem is not too full.

Why do I need a section profile in Btrfs?

For the constraints of the profiles please refer to mkfs.btrfs (8) , section PROFILES. The way balance operates, it usually needs to temporarily create a new block group and move the old data there, before the old block group can be removed. For that it needs the work space, otherwise it fails for ENOSPC reasons.