Squash the butter

Or in other words, file compression. This is a very short stub of an article to explain why my laptop has transparent compression enabled on the filesystem. And kinda how I make it all work.

It starts with a little investigation into btrfs as I was somewhat interested by its advanced features, such as reflink copies, snapshots, and of course transparent compression.

Ok, so I might have dropped this draft a while ago. To cut it all short it makes sense to enable compression across my entire filesystem. Especially when combined with the ability to remove and combine duplicated extents across the filesystem (not that I can claim to fully understand exactly how it all works).

What I do know is what I did.

  1. Enable btrfs in the kernel
  2. Use btrfs-convert to turn my ext4 filesystem into btrfs
  3. Reconfigure my systems /etc/fstab file
    1. Set the mount type to btrfs
    2. Enable compression with zstd for the whole filesystem

With that done the compression would automatically start to take place, as and when files are accessed they would get automatically compressed using zstd compression, chosen for its good realtime performance.

The only thing I’ve done since then is attempted to make good use of the ability of btrfs to deduplicate shared extents. And no, I don’t really know exactly what that means, but the gist of it is files that are identical can exist as multiple references to the same file. But extents allow you to share parts of files, meaning files that are really similar but differ in only a small way can be part references to the same file, with unique bits added on top.

NOTE:

Extent sharing _can_ cause performance issues as there are situations that would require walking back extents. I'd suggest you do your own research before trusting what a random person on the internet says "worked for me".