ZFS: How to check compression efficiency

 

If you have enabled compression on a ZFS folder you can check to see just how much disk space you’re saving. Use the following command:

 

sudo zfs get all [poolname]/[folder] | grep compressratio

 

An example:

 

sudo zfs get all backup01/data | grep compressratio

 

returns the following:

 

backup01/data compressratio  1.50x  –

 

Here we can see we have a compression ratio of 1.5x. Compression is an excellent way of reducing disk space used and improving performance, so long as you have a modern CPU with enough spare power to handle it. Some data will not be easily compressible and you may see less benefit – other data will be much more compressible and you may reach quite high compression ratios.

 

If we run the same command on a folder full of already-compressed RAW image files:

 

sudo zfs get all backup01/photos | grep compressratio

backup01/photos compressratio 1.05x

 

…we can see that they do not compress as easily as the documents in the data folder, giving us only a 1.05x compression ratio. You can see the compression ratio of all of your ZFS pools and folders with the following:

 

sudo zfs get all | grep compressratio

 

Check your own datasets and see how much you are saving!


Posted

in

, ,

by

Comments

One response to “ZFS: How to check compression efficiency”

  1. […] Note that you don’t need the leading / for the pool, and that you can set this at a pool level and not just on sub-datasets. 1 is the lowest level of compression (less CPU-intensive, less compressed) where gzip-9 is the opposite – often quite CPU intensive and offers the most compression. This isn’t necessarily a linear scale, mind, and the type of data you are compressing will have a huge impact on what sort of returns you’ll see. Try various levels out on your data, checking the CPU usage as you go and the compression efficiency afterwards – you may find that 9 is too CPU-intensive, or that you don’t get a great deal of benefit after a certain point. Note that when you change the compression level it only affects new data written to the ZFS dataset; an easy way of testing this is to make several sets, set a different level of compression on each and copy some typical data to them one by one while observing. We discussed checking your compression efficiency in a previous post. […]