0
I've recently discovered the marvel of a modern filesystem, btrfs. After playing with it for a few hours, I decided to dive straight in and converted my entire /home
partition using the btrfs-convert
tool. After that process was completed, I was left with a perfectly functional filesystem, except for the strange fact that it seemed to have nearly 80 gigabytes of metadata (for a 420 gb block device), and it seemed to have allocated off 123 gigabytes (30% of the entire device) for metadata.
root@asmodeus:/home/robbie# btrfs fi df /home
Data, single: total=249.50GiB, used=210.80GiB
System, single: total=32.00MiB, used=24.00KiB
Metadata, single: total=123.00GiB, used=79.69GiB
I then realized that I have forgotten the last step in the filesystem conversion process, a defragmentation. I initiated the defrag with btrfs fi defrag -v -c -r -f /home
(The article on converting ext3 to btrfs only said to use the recursion flag, but I decided it couldn't hurt to throw some compression in the mix and flush the changed to disk right away, and be verbose because that's how I roll) and that has been running for a good hour now. At first I was going to leave asking the question until after the defrag had finished, but I noticed that while the amount of metadata was slowly going down, my disk usage was actually going up.
root@asmodeus:/home/robbie# btrfs fi df /home
Data, single: total=249.50GiB, used=223.15GiB
System, single: total=32.00MiB, used=24.00KiB
Metadata, single: total=123.00GiB, used=65.48GiB
I noticed that the amount of data has gone up by about the same amount that the metadata has gone down. I could see this being a temporary artefact of adding the compression, and perhaps after the defrag has completed all will be well, but I'd still like to know what is up with the ludicrous allocation for metadata? Am I able to reduce it?
Progress report: After running for many hours, this is what the usage looks like
robbie@asmodeus:~$ btrfs fi df /home
Data, single: total=249.50GiB, used=230.50GiB
System, single: total=32.00MiB, used=24.00KiB
Metadata, single: total=123.00GiB, used=12.23GiB
The metadata usage has reduced by nearly 60 gigabytes (wow), and the data usage has increased by 32 gigabytes (It appears to be less, I moved some 12 gigabytes of media files to an external disk). In terms of disk usage, things look better, but the question remains why is so much space allocated? Now that I've reduced the amount of metadata that needs to be stored, may I reallocate some of the metadata space as data space?
@DragonLord flagged – Robbie Mckennie – 2015-04-28T01:32:40.570
The duplicate answer does not completely answer the question. The problem is that after defragmentation, BTRFS does not automatically resize the metadata allocation, which was sized appropriately given the initial level of metadata after conversion – Richie Frame – 2015-04-29T01:12:47.337
https://superuser.com/questions/890074/understanding-metadata-usage-behavior-in-a-newly-converted-btrfs-filesystem is a more accurate duplicate of this question, namely "why does this occur and how do I fix it" – Richie Frame – 2015-04-29T02:16:01.803