🗒️ ZFS Management Cheat Sheet
📦 Pools
Create a pool (mirror, RAIDZ, stripe):
# Stripe (fast, no redundancy)
zpool create poolname /dev/sdX /dev/sdY
# Mirror (RAID1-like)
zpool create poolname mirror /dev/sda /dev/sdb
# RAIDZ1 (like RAID5)
zpool create poolname raidz1 /dev/sd[a-c]
# RAIDZ2 (like RAID6)
zpool create poolname raidz2 /dev/sd[a-e]
Add vdev to existing pool:
zpool add poolname mirror /dev/sdX /dev/sdY
Replace a failed disk:
zpool replace poolname old-disk new-disk
Export/import pool:
zpool export poolname
zpool import poolname
🔍 Pool Status & Health
Check health:
zpool status
Detailed I/O:
zpool iostat -v 1
Show available pools:
zpool list
🧩 Datasets & Filesystems
Create dataset:
zfs create poolname/dataset
Set mountpoint:
zfs set mountpoint=/mnt/data poolname/dataset
Show datasets:
zfs list
Destroy dataset:
zfs destroy poolname/dataset
🖼️ Snapshots & Clones
Take snapshot:
zfs snapshot poolname/dataset@snapname
List snapshots:
zfs list -t snapshot
Rollback to snapshot:
zfs rollback poolname/dataset@snapname
Clone snapshot (writable):
zfs clone poolname/dataset@snapname poolname/clone
🧹 Scrubbing & Maintenance
Start scrub:
,.l
Pause scrub (OpenZFS 2.1+):
zpool scrub -p poolname
Stop scrub:
zpool scrub -s poolname
View scrub progress:
zpool status poolname
Clear errors after replacing/rebuilding:
zpool clear poolname
⚙️ Properties & Tuning
View properties:
zfs get all poolname/dataset
Set compression:
zfs set compression=lz4 poolname/dataset
Set quota:
zfs set quota=100G poolname/dataset
Enable deduplication (⚠️ RAM heavy, use cautiously):
zfs set dedup=on poolname/dataset
🛠️ Recovery & Troubleshooting
Import pool after crash:
zpool import -f poolname
Import with recovery options:
zpool import -F poolname
Offline a disk (for replacement):
zpool offline poolname /dev/sdX
Online a disk:
zpool online poolname /dev/sdX
🕒 Useful One-Liners
-
Check scrub history:
zpool history | grep scrub -
Monitor ARC (Linux):
arcstat.py 1(install
arcstatfrom OpenZFS tools) -
Estimate space (including snapshots):
zfs list -o space