btrfs and missing free space
I converted my ext4 partition to btrfs and deleted the save subvolume after doing so. Then I enabled the compression (lzo) of the filessystem in the fstab file and everything is correct so far.
Then I forced the compression of all files using the defragmentation command with the parameter -c that the new compression is applied to all files.
While doing so, I noticed that my ssd got completly filled up - before I had 6gigs of free space. No I got nothing left.
easteregg@x201s:~$ btrfs fi df /
Data: total=50.00GB, used=49.17GB
System: total=32.00MB, used=4.00KB
Metadata: total=24.50GB, used=9.86GB
and
easteregg@x201s:~$ df -ha
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 75G 60G 852M 99% /
So now. How can I regain my free space. I expected to gain more space because of the lzo compression. And now!
The fs is correctly mounted.
easteregg@x201s:~$ mount
/dev/sda1 on / type btrfs (rw,noatime,ssd,compress=lzo)
Any ideas how to fix this issue?
I know this question is old - but as of today the balance command solves this stuff:
During conversion a lot of space will be allcoated to move stuff to it. Once it is allocated, it will not show up as "free" or "unallocated" anymore. To fix this simply start a balance
btrfs balance start "path"
you can also tell the balance command, to only balance chunks, which are used for acertain percentage - like 0% which would mean the chunks are empty:
btrfs balance start "path" -dusage=0 -musage=0
parameter -d means options for the data. parameter -m means options for the metadata.
play with the balance command, it should help.
Look at the output from btrfs fi df
:
Data: total=50.00GB, used=49.17GB
System: total=32.00MB, used=4.00KB
Metadata: total=24.50GB, used=9.86GB
The total
part is the allocated space, while used
is the actually used by btrfs. The difference between total
and used
(around 15 GB) is your missing space. As you can see, it has already been allocated for metadata blocks.
I only have hobby experience with btrfs, but I don't think a ext4 conversion is the best way to create a well laid out btrfs filesystem. Fortunately, you can rebalance the whole filesystem to make it re-do all allocations.
As always, use backups.