Imran's Blog
Stuff I feel like blogging about.

ZFS, video files and compression

Posted on

Did this earlier this week and thought I would share. My server stores video files for TV shows and movies I have watched. Other types of files exist but it's almost entirely video files. These take up quite a bit of space.

The server consists of a single zpool, aptly named "mediafiles". ZFS supports compression, but the default is to have it off. Enabling compression is a single command away (man zfs-set and man zfsprops). One thing to note, compression works going forward. This means that existing files are not compressed, but any new files written to the pool will be. If you do want to retroactively compress files, you will need to rewrite your files to disk (by moving and unmoving).

This is what I did for my 12 TB of data. If you are smarter than, or me from the future you would know this is an astoundingly stupid idea. This is why:

  1. If you read the man page properly, a file has to be compressible by 7/8 of its original size for ZFS to consider it for compression
  2. Video files are already compressed, the codec determines the compression.

This means, that after I had put 12 TB of write load on my zpool, my compression remained at 1.00x.

❯ doas zfs get all | rg compress
mediafiles                  compressratio         1.00x                  -
mediafiles                  compression           zstd                   local

Yay 🤦.