OpenZFS on Linux — Setup, Pools and Snapshots
What is OpenZFS?
OpenZFS is an advanced filesystem and volume manager in one. Originally created by Sun Microsystems for Solaris, today it’s developed as an open source project and available on Linux, FreeBSD, macOS, and Windows.
ZFS stands out from traditional filesystems (ext4, XFS) because it:
- Combines filesystem with volume manager — no need for separate LVM
- Guarantees data integrity — every block has a checksum
- Supports snapshots — instant, without copying data
- Offers compression and deduplication — saves space on the fly
- Provides RAID-Z — better than traditional RAID5/6
Basic Concepts
Pool
A pool is a collection of disks from which ZFS creates a single storage space. It’s the equivalent of a volume group in LVM, but much more powerful.
# Create a pool from a single disk
zpool create mypool /dev/sdb
# Create a mirror pool (RAID1) from two disks
zpool create mypool mirror /dev/sdb /dev/sdc
# Create a RAID-Z1 pool (equivalent to RAID5) from three disks
zpool create mypool raidz1 /dev/sdb /dev/sdc /dev/sdd
Dataset
A dataset is a logical container for data within a pool — something like a directory, but with its own settings (compression, quotas, snapshots).
# Create datasets
zfs create mypool/documents
zfs create mypool/backups
zfs create mypool/vms
# Each dataset is a separate "filesystem" with its own options
zfs set compression=lz4 mypool/backups
zfs set quota=100G mypool/vms
Snapshot
A snapshot is a point-in-time image of a dataset’s state. Creation is instant and takes no additional space (until data changes).
# Create a snapshot
zfs snapshot mypool/documents@before-upgrade
# List snapshots
zfs list -t snapshot
# Restore data from snapshot
zfs rollback mypool/documents@before-upgrade
Installation on Linux
Ubuntu/Debian
sudo apt install zfsutils-linux
Fedora
sudo dnf install https://zfsonlinux.org/fedora/zfs-release-2-4.fc$(rpm -E %fedora).noarch.rpm
sudo dnf install zfs
sudo modprobe zfs
Arch Linux
# From AUR
yay -S zfs-dkms
After installation, load the module:
sudo modprobe zfs
Practical Examples
Creating Pools and Datasets
# Mirror pool on two disks
sudo zpool create tank mirror /dev/sdb /dev/sdc
# Datasets for different purposes
sudo zfs create tank/home
sudo zfs create tank/docker
sudo zfs create tank/databases
# Enable compression (recommended!)
sudo zfs set compression=lz4 tank
# Check status
zpool status tank
zfs list
Snapshots and Backup
# Daily snapshot before update
sudo zfs snapshot tank/home@$(date +%Y-%m-%d)
# Send snapshot to remote server
zfs send tank/home@2026-02-05 | ssh backup-server zfs receive backup/home
# Incremental backup (only changes)
zfs send -i tank/home@2026-02-04 tank/home@2026-02-05 | ssh backup-server zfs receive backup/home
Compression
# Check compression ratio
zfs get compressratio tank
# Example output for text data:
# NAME PROPERTY VALUE SOURCE
# tank compressratio 2.50x -
LZ4 provides an excellent balance between performance and compression. For archives, you can use zstd:
sudo zfs set compression=zstd tank/archives
RAID-Z: Better Than Traditional RAID
ZFS offers three RAID-Z levels:
- RAID-Z1 — equivalent to RAID5, tolerates 1 disk failure
- RAID-Z2 — equivalent to RAID6, tolerates 2 disk failures
- RAID-Z3 — tolerates 3 disk failures
# RAID-Z2 on 6 disks (4 for data, 2 for parity)
sudo zpool create tank raidz2 /dev/sd{b,c,d,e,f,g}
Why is RAID-Z Better?
- No “write hole” — ZFS writes data and metadata atomically
- Checksums — detects and repairs silent data corruption (bit rot)
- Scrub — regular verification of all data integrity
# Run scrub (recommended monthly)
sudo zpool scrub tank
# Check progress
zpool status tank
Useful Commands
# Pool status
zpool status
zpool list
# List datasets
zfs list
# Dataset properties
zfs get all tank/home
# Operation history
zpool history tank
# Replace failed disk
zpool replace tank /dev/sdb /dev/sdx
# Import pool from another system
zpool import tank
When to Use ZFS?
Yes:
- NAS and storage servers
- Servers with virtual machines (snapshots!)
- Backup and archival
- Environments where data integrity is critical
No:
- Single disk in a laptop (ext4 is enough)
- Systems with <8 GB RAM (ZFS likes memory)
- Older kernels without ZFS support
Summary
OpenZFS is a powerful tool that combines a filesystem, volume manager, and data protection in one package. Snapshots, compression, RAID-Z, and checksums make it ideal for servers and storage. It requires some learning, but pays off handsomely — especially when you first restore data from a snapshot in 2 seconds instead of from backup over 2 hours.