Use this when better compression ratio is worth more CPU.
ZSTD
ZSTD (Zstandard) is a lossless compression algorithm with adjustable levels, giving better ratios than LZ4 at moderate CPU cost. It is used in ZFS, Btrfs, backup tools and Linux kernels.
1. ZSTD: better ratio than LZ4, tunable levels.
2. Low levels (1–3) are fast.
3. Higher levels for archives.
4. Decompression stays fast.
5. Use for backups/logs.
data → ZSTD level n → 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
- High levels on write-heavy workloads.
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.
- ZSTD has adjustable levels.
- Higher levels give better ratio and cost CPU.
- Good for backups and archives.
zfs set compression=zstd-3 <ds>— ZFS zstd levelzstd -b3 -e9 <file>— benchmark levelsmount -o compress=zstd:3— Btrfs
ReferenceHow it works1 section · depth on demand
Reference
zfs set compression=zstd-3 tank/archive
zstd -b1 -e10 file # benchmark levels 1-10
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
ZSTD trades more CPU for better compression than LZ4
zfsprops(7) lists zstd, zstd-N (levels 1–19) and zstd-fast/zstd-fast-N among the compression values. As with every compression setting, changing it affects only newly written data.
# zfs set compression=zstd tank/archive # zstd default level
# zfs set compression=zstd-9 tank/cold
# zfs set compression=zstd-fast tank/logs
# zfs get -r compression,compressratio tank
NAME PROPERTY VALUE SOURCE
tank/archive compression zstd local
tank/archive compressratio 2.41x -
tank/data compression lz4 local
tank/data compressratio 1.58x -
Choosing a level
| Setting | Typical use |
|---|---|
lz4 | General purpose and VMs: lowest CPU |
zstd-fast | Logs and text, close to LZ4 speed |
zstd (default level) | Archives, backups, file shares |
zstd-9 and higher | Cold data written once; writes become CPU-bound |
Practical points
- Higher levels mainly cost CPU on writes. Decompression stays fast across levels.
- Mixed datasets are fine: set compression per dataset (
tank/archivezstd,tank/vmlz4). zstdrequires thezstd_compresspool feature, so older pools or systems may not support it. Check withzpool get feature@zstd_compress.- Replication with
zfs send -ckeeps blocks compressed in the stream. The receiver stores them as sent.
Measure, don't guess
Copy a representative sample into test datasets with different settings and compare compressratio and write time. The right choice depends on data type and CPU headroom.
Documented example, not captured output.
Quick reference
| Level | Speed | Ratio | Use |
|---|---|---|---|
| zstd-1…3 | Close to LZ4 | Better than LZ4 | General data |
| zstd-9…12 | Slower | Higher | Archives, cold data |
| zstd-19 | Very slow | Highest | Write-once archives |
Decompression stays fast at all levels, so high levels mainly cost write speed. ZFS: zfs set compression=zstd-3 tank/data; Btrfs: mount -o compress=zstd:3.
Reference
ZSTD offers levels (1–19, plus negative fast levels). Level 1–3 is close to LZ4 speed with better ratio; high levels suit archives. Supported in ZFS (2.0+), Btrfs, Linux kernels and many backup tools.
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 → ZSTD. 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%