Balance Filters

From btrfs Wiki
Jump to: navigation, search

Balancing to fix filesystem full errors

This is explained in more details on Marc's Blog on Fixing Btrfs Filesystem Full Problems, but basically there are times when btrfs will need rebalancing to fix issues with chunks being misbalanced.

Keys points:

  • If you are getting out of space errors due to metadata being full, before 3.18 (where it's now automatic), you can try this:
btrfs balance start -v -dusage=0 /mnt/btrfs
  • If your data chunks are misbalanced, look at how much space is really used in percentage and you can feed that to -dusage in smaller increments starting from 10. This will ask btrfs to rebalance all chunks that are not at that threshold (bigger number means more work). Rebalancing means chunks under that usage threshold will have their data moved to other chunks so that they can be freed up and made available for new allocations (fixing your filesystem full problem):
btrfs balance start -dusage=55 /mnt/btrfs

Other Examples

Convert data to raid1 after mkfs with defaults

You want to increase redundancy for data as well, with at least 2 devices you can do:

$ mkfs.btrfs /dev/sda1 /dev/sdb1
$ mount /dev/sda1 /mnt
[...]
$ btrfs fi df /mnt

output:

Data, RAID0: total=409.50MB, used=0.00
Data: total=8.00MB, used=0.00
System, RAID1: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=204.75MB, used=24.00KB
Metadata: total=8.00MB, used=0.00
$ btrfs fi balance start -dconvert=raid1 /mnt
$ btrfs fi df /mnt

output:

Data, RAID1: total=819.12MB, used=128.00KB
System, RAID1: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=460.75MB, used=24.00KB
Metadata: total=8.00MB, used=0.00

Convert data and metadata to raid1 after mkfs with defaults

The above example won't give you an actual RAID1 configuration if you haven't already mirrored your metadata, as it only mirrors data. You can see this if your output after running the above commands looks like the following:

Data, RAID1: total=819.12MB, used=128.00KB
System, DUP: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, DUP: total=460.75MB, used=24.00KB
Metadata: total=8.00MB, used=0.00

You can also see it didn't work out the way you might have wanted to because

$ btrfs fi show 

will report an unbalanced amount of space used on your devices.

To actually get RAID1 where you are left with a working copy of the filesystem after you lose one of your devices, you must specify the following to rebalance to RAID1:

$ btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt
$ btrfs fi df /mnt


For more examples read this email: patch

Personal tools