Use this when compression happens on the write path.
Inline Compression
Inline compression compresses data as it is written, before it reaches disk, so the saving is immediate and fewer bytes are written. It costs CPU on the write path, unlike post-process compression.
1. Inline compression happens at write time.
2. Saves space immediately; may reduce I/O.
3. Fast algorithms keep latency low.
4. Monitor CPU.
5. Default on many arrays and filesystems.
write → compress inline → 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
- Changing compression and expecting existing data to be recompressed (only new writes are).
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.
- Savings are immediate.
- Fewer bytes are written to disk.
- It adds CPU on every write.
zfs set compression=lz4 <ds>— inline ZFSmount -o compress=zstd:3 <dev> <mnt>— Btrfs inlinearray inline compression— vendor
ReferenceHow it works1 section · depth on demand
Reference
Inline compression happens before writing, so it reduces disk I/O and capacity. It is the default recommendation on ZFS (lz4/zstd) and many arrays.
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
Inline compression compresses data in the write path, before it reaches disk
With inline compression, each block is compressed as it is written. There is never an uncompressed copy on disk. Post-process compression (some dedup systems, some arrays) writes data first and compresses it later in background jobs.
| Aspect | Inline | Post-process |
|---|---|---|
| Space saved | Immediately | After the job runs |
| CPU | On every write | In scheduled windows |
| Write latency | Small extra cost | None at write time |
| Disk writes | Fewer bytes written | Full writes, then rewrites |
ZFS compresses inline
zfsprops(7) lists the compression algorithms (lz4, zstd, gzip-N and others) and notes that changing the property affects only newly written data. Blocks are allocated in whole sectors; if compression doesn't save at least one sector, the block is stored uncompressed.
# zfs set compression=lz4 tank/vm
# zfs get compression,compressratio tank/vm
# zpool iostat -v tank 5 # fewer bytes written than the application sends
Where inline compression sits in the stack
| Layer | Examples |
|---|---|
| File system | ZFS, Btrfs (compress=zstd), NTFS compression |
| Block layer | VDO (Linux), array inline compression |
| Application | Database page or column compression, compressed backups |
When it helps performance
On fast CPUs with LZ4 or ZSTD-fast, inline compression often makes storage faster, because fewer bytes are read and written. The exceptions are CPU-bound hosts, already-compressed data (little gain, small cost) and very high compression levels on write-heavy data.
Avoid compressing twice
Don't stack compression layers (application, then VDO, then array) without measuring. Data compressed once gains almost nothing the second time, but still pays the CPU cost.
Documented example, not captured output.
How it works
Data is compressed before it is written, reducing both capacity used and disk writes. Fast algorithms like LZ4 often make writes faster because less data reaches the disks.
Reference
zfs set compression=lz4 tank/data
zfs get compressratio tank/data
mount -o compress=zstd:3 /dev/sdb /data # Btrfs
Documented example, not captured output.
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 → Inline Compression. 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%