18

I have a 256GB SSD disk on which I converted my ext4 root FS to btrfs. I erased the ext4 backup subvolume, enabled compression and defragmented recursively to enable it on all files.

btrfs fi df / has an output that worries me though:

Data: total=148.00GB, used=106.11GB
System: total=32.00MB, used=16.00KB
Metadata: total=65.00GB, used=2.04GB

If I understand the output correctly, 65GB (1/4 of my disk!) is reserved for meta-data and not available for storing files. If this is correct, it would be a huge waste of my disk space. Am I understanding correctly? Can the metadata-allocated portion of my disk be resized?

Gnurou
  • 423
  • 4
  • 9

2 Answers2

17

First, make sure your kernel and the BTRFS user-space is up-to-date.

According to the BTRFS FAQ, you cannot resize the metadata block size. You can, however, try to run btrfs balance start -m <mount point> which will reallocate the metadata across the entire disk and, as a side effect, possibly free up unallocated space.

If that doesn't work, you may have to backup your data and recreate the filesystem. (Take a look at this for more info.)

dannyman
  • 140
  • 5
hololeap
  • 1,321
  • 1
  • 9
  • 14
  • Thanks for the answer. Kernel is 3.11.2, btrfs-tools are v0.20-rc1 so I don't think I'm out of date here. I tried to run a balance but then I hit the following bug: http://www.spinics.net/lists/linux-btrfs/msg26977.html and don't feel like compiling a newer kernel just for this. :P What I wonder is whether these 65GB are the metadata block that cannot be resized, or if that term refers to something else. Otherwise I really don't understand how the metadata block got created with that size in the first place. – Gnurou Oct 04 '13 at 15:21
  • Unfortunately, I am only a user of btrfs and not an expert, so my help is limited. In any case, it's possible there is a flaw in the conversion process from ext4. – hololeap Oct 05 '13 at 16:05
  • 12
    So, the necessary patch made it into the stable kernel, and I have tried what you suggested. Balancing indeed reduced the amount of reserved area for meta-data down to 3GB, and the claimed space now appears as free space in 'df'. Note that you don't need to rebalance the whole disk, you can do **btrfs balance start -m ** to only rebalance the metadata, which is much faster. Thanks for the insightful answer! – Gnurou Oct 25 '13 at 06:03
  • Glad I could help! – hololeap Nov 13 '13 at 04:32
  • "you cannot resize the metadata block size". This is irrelevant to this question - the FAQ talks about the allocation unit size, not the amount of space allocated for the metadata. – Vladimir Panteleev Sep 04 '16 at 15:52
2

This will decrease metadata size.

sudo btrfs balance start -v -musage=0 /path
Benjamin
  • 31
  • 2