Use this when choosing a fast default compression algorithm.
LZ4
LZ4 is a very fast lossless compression algorithm with modest ratios. It is the usual default in ZFS and many arrays because its CPU cost is low and it quickly gives up on incompressible data.
1. LZ4: very fast, modest ratio.
2. Early abort on incompressible data (ZFS).
3. Safe default.
4. Almost no CPU cost.
5. Good for VMs and general data.
data → LZ4 → stored
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Disabling compression out of habit.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- LZ4 is very fast with modest ratio.
- It aborts early on incompressible data.
- It is the usual ZFS default.
zfs set compression=lz4 <ds>— enablelz4 -b <file>— benchmarkzfs get compressratio <ds>— result
ReferenceHow it works1 section · depth on demand
Reference
zfs set compression=lz4 tank
lz4 -b1 file # benchmark
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
LZ4 is the usual default choice for ZFS compression
zfsprops(7) lists the compression values: on, off, lz4, lzjb, zle, gzip-N, zstd, zstd-N and zstd-fast. on selects the current default algorithm — lz4 when the lz4_compress pool feature is enabled — so setting lz4 explicitly pins the choice.
# zfs set compression=lz4 tank/data
# zfs get compression,compressratio,logicalused,used tank/data
NAME PROPERTY VALUE SOURCE
tank/data compression lz4 local
tank/data compressratio 1.62x -
tank/data logicalused 1.30T -
tank/data used 820G -
Behaviour worth knowing
| Documented behaviour | Consequence |
|---|---|
| Changing the property affects only newly written data | Existing data stays as it was until rewritten (for example zfs send | zfs receive) |
| Blocks are allocated in whole sectors; if compression saves less than a sector, the block is stored uncompressed | Incompressible data costs little CPU and no space |
Any setting except off stores zero-filled blocks as holes | Sparse files and zeroed VM disks shrink |
compressratio refers to used space of the dataset | Compare logicalused and used for the absolute saving |
When to choose something else
| Data | Choice |
|---|---|
| General files, VM images, databases | lz4 — fast, low CPU |
| Archive data where CPU is plentiful | zstd or zstd-N for better ratio |
| Already compressed media, encrypted blobs | Little gain; lz4 is still cheap |
Measure on real data: copy a representative sample into a test dataset and compare compressratio.
*The compression ratio and logical versus physical usage figures are illustrative dataset properties, not measured savings.*
How it works
LZ4 is a very fast lossless algorithm with a moderate ratio, designed for speed over size. It is the default compression on ZFS for that reason.
Reference
LZ4 compresses at several hundred MB/s per core and decompresses faster. ZFS uses early-abort: if a block does not compress, it is stored uncompressed, so enabling LZ4 rarely hurts.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Compression → LZ4. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html · confidence 94%