Pcornel
Browse topics
Options
Recent
Favorites
Storage · Technical reference

LZ4

Direct answer

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.

When to use this

Use this when choosing a fast default compression algorithm.

First 30 seconds

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.

Operational verification

data → LZ4 → stored

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Storage architecture and operations
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformStorage architecture and operations
Scope / prerequisiteUse this when choosing a fast default compression algorithm.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points
  • LZ4 is very fast with modest ratio.
  • It aborts early on incompressible data.
  • It is the usual ZFS default.
Key checks
  • zfs set compression=lz4 <ds> — enable
  • lz4 -b <file> — benchmark
  • zfs 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 behaviourConsequence
Changing the property affects only newly written dataExisting 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 uncompressedIncompressible data costs little CPU and no space
Any setting except off stores zero-filled blocks as holesSparse files and zeroed VM disks shrink
compressratio refers to used space of the datasetCompare logicalused and used for the absolute saving

When to choose something else

DataChoice
General files, VM images, databaseslz4 — fast, low CPU
Archive data where CPU is plentifulzstd or zstd-N for better ratio
Already compressed media, encrypted blobsLittle 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.*

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docStorage architecture and operations current

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%
Confirmation

Confirm action

Continue?