ZFS Compression: Difference between revisions

From Lustre Wiki
Jump to navigation Jump to search
m (sentence needed a 'the')
(Merge into ZFS, pending deletion)
Tag: Replaced
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
ZFS supports transparent compression of data at the block level for datasets. Enabling compression can improve storage efficiency by decreasing the amount of data written to disk and improve read performance for large files, as less data needs to be read from disk.
see
 
[[ZFS#compression]]
If desired, compression will need to be enabled individually for all relevant OSTs.
 
== Check ZFS compression ==
<pre>zfs get compression <OST/dataset/here></pre>
== Set ZFS compression ==
 
<pre>zfs set compression=on <OST/dataset/here></pre>
turns on compression with the default algorithm (lz4 since ZFS version 0.6.5). You can chose values other than "on" for the compression algorithm, see 'man zfsprops' for details.
To use a different algorithm, use for example "compression=zstd" instead of "on".
 
'''lz4''' is likely the best choice now. It has been tested extensively, and provides very good compression balanced with performance. It implements an early abort feature<ref>https://github.com/openzfs/zfs/blob/e0bf43d64ed01285321bf6c3a308f699c5483efc/module/zfs/lz4_zfs.c#L520</ref>, meaning it stops trying to compress if initial compression results do not meet a threshold, so performance with incompressible data isn't degraded.
== Check compression ratio ==
 
On OSS:
<pre>zfs get compressratio <OST/dataset/here></pre>
 
On client machines:
<pre>du --apparent-size -h <file/dir></pre> will show logical usage of a file (in human readable units), whereas <pre>du -h <file></pre> will show actual usage on disk (in human readable units).
 
[[Category:ZFS]][[Category:Howto]]

Latest revision as of 12:21, 5 June 2026