Linux – btrfs: how to calculate btrfs compression space savings

btrfslinux

I've enabled compression (mounted with compress=lzo) for my btrfs partition and used it for a while.

I'm curious about how much benefit the compression brought me and am interested in the saved space value (sum of all file sizes) - (actual used space).

Is there any straightforward way to get this value, or would I have to write a script that sums up e.g. df output and compres it to btrfs filesystem dfoutput?

Best Answer

In Debian/Ubuntu:

apt install btrfs-compsize
compsize /mnt/btrfs-partition

In Fedora:

dnf install compsize
compsize /mnt/btrfs-partition

output is like this:

Processed 123574 files, 1399139 regular extents (1399139 refs), 69614 inline.
Type       Perc     Disk Usage   Uncompressed Referenced  
TOTAL       73%      211G         289G         289G       
none       100%      174G         174G         174G       
lzo         32%       37G         115G         115G
Related Question