brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: zfs get compressratio shows how much space compression saves

Zfs
~/tips/tip-zfs-compressratio

zfs get compressratio tank/media

See how much disk space ZFS compression saves per dataset.

I like a feature better when I can see it working. ZFS compression is easy to switch on and then forget, so I’d want to know whether it is actually earning its keep on a dataset.

Ask ZFS for the compression ratio of a dataset:

zfs get compressratio tank/media
zfs get -r compressratio,compression tank

The first line reports one dataset. The second walks every child dataset of the pool and also prints which compression algorithm each one uses, so you can see the setting and the result side by side. A value like 1.45x means the data takes up about a third less room on disk than its uncompressed size.

Text, logs, databases and backups usually compress well. Video, photos and anything already zipped barely shrink, so a ratio of 1.00x on a media dataset is normal, not a sign that compression is broken.

A caveat: the ratio only covers data written after compression was turned on. Older blocks stay as they were until you rewrite them, so a freshly changed dataset can look disappointing for a while.

One more detail: zfs get -r -t filesystem compressratio tank keeps snapshots out of the list, which makes a pool with many of them far easier to read.

Further reading: zfs-get(8) man page, zfsprops(7), compressratio

More Zfs tips zpool status -x All Zfs tips (2) All topics

Link