btrfs lzo Compression

I have a 6TB (2x3TB RAID0) btrfs filesystem that’s nearly full, and I’ve read that lzo compression can actually speed some operations up in addition to squeezing more space out of my volume.

Before:

Device size: 5.46TiB
Device allocated: 5.33TiB
Device unallocated: 130.02GiB
Device missing: 0.00B
Used: 5.32TiB
Free (estimated): 135.67GiB (min: 70.66GiB)
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 512.00MiB (used: 0.00B)

After:

Device size: 5.46TiB
Device allocated: 5.20TiB
Device unallocated: 267.02GiB
Device missing: 0.00B
Used: 5.18TiB
Free (estimated): 279.15GiB (min: 145.64GiB)
Data ratio: 1.00
Metadata ratio: 2.00
Global reserve: 512.00MiB (used: 0.00B)

That’s an increase of 131.35GiB, which ain’t shabby.

To force the compression, I used this command line:
btrfs filesystem defragment -clzo -vrf /media/btrfs/

The -c option is for specifying a compression algorithm, lzo in this case.

-v is for verbose output to show which file it’s currently processing

-r is for recursive

-f is to flush each file to disk as the defrag works

On this volume it took about 24hrs to run.