brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: btrfs filesystem usage tells you the real free space on btrfs filesystems

Filesystems
~/tips/tip-filesystems-btrfs-usage

sudo btrfs filesystem usage /mnt/pool

See allocated and unallocated space when df gives a misleading answer.

Btrfs can say the disk is full while df still shows room. It hands out space in large chunks, separately for data and metadata, and df cannot show that.

sudo btrfs filesystem usage /mnt/pool

At the top you get the device size, how much is allocated to chunks, how much is unallocated and an estimate of free space for data. Below that is a breakdown for data, metadata and system, with the RAID profile of each.

Two lines matter most to me. Device unallocated is what can still be turned into new chunks. Free (estimated) is the figure I trust for how much more data fits.

If unallocated is near zero while the data chunks are half empty, a filtered balance gives space back:

sudo btrfs balance start -dusage=50 /mnt/pool

This rewrites data chunks that are less than half used.

Balance moves a lot of data, so run it when the machine is quiet and keep backups current, as with any operation that rewrites a filesystem. On a RAID profile, read the estimate as exactly that, since mirrored copies use double the raw space. A pool with many snapshots can stay full even after you delete files, because the snapshots still hold the old blocks.

Further reading: btrfs filesystem documentation, btrfs balance documentation

More Filesystems tips sudo fsfreeze -f /srv/data filefrag /var/lib/libvirt/images/vm1.qcow2 sudo tune2fs -l /dev/sdX1 | grep -iE 'mount count|check' findmnt --df lsblk -f All Filesystems tips (6) All topics

Link