Recompressing BTRFS files

Ages ago, I reconfigured my postfix/dovecot mail server to use BTRFS for it’s mail store; thinking that the mail files would compress fairly well so it’d be an efficient use of disk space.

I’d just mounted the volume with compress=lzo and not thought anything else about it.

Yesterday, Icinga/Nagios started nagging me that the disk was 80% full…..

So I thought I’d see if changing the compression algorithm to zstd would make any difference.

btrfs filesystem defrag -czstd -r /srv/mail -v

Result – disk usage went from 80% (40Gb) to 57% (28Gb) of a 50Gb volume.