Pool Operations

Creating Pools

# Create basic pool
zpool create tank /dev/sda

# Mirror configuration
zpool create tank mirror /dev/sda /dev/sdb

# RAIDZ configuration
zpool create tank raidz /dev/sda /dev/sdb /dev/sdc

# With cache devices
zpool create tank mirror /dev/sda /dev/sdb cache /dev/sdc

Managing Pools

# List pools
zpool list
zpool status tank

# Import/export
zpool import [-d dir] pool
zpool export pool

# Scrub and repair
zpool scrub tank
zpool clear tank

# Add/remove devices
zpool add tank mirror /dev/sdc /dev/sdd
zpool remove tank /dev/sdc

Dataset Operations

Dataset Management

# Create dataset
zfs create tank/dataset

# Set mountpoint
zfs set mountpoint=/mnt/data tank/dataset

# Enable compression
zfs set compression=lz4 tank/dataset

# Create snapshot
zfs snapshot tank/dataset@snapshot1

# Clone snapshot
zfs clone tank/dataset@snapshot1 tank/clone

Properties and Quotas

# Set quota
zfs set quota=100G tank/dataset

# Set reservation
zfs set reservation=50G tank/dataset

# Inherit property
zfs inherit compression tank/dataset

# List properties
zfs get all tank/dataset
zfs get compression,quota tank/dataset

Advanced Features

Snapshot Management

# Create recursive snapshot
zfs snapshot -r tank@snapshot1

# List snapshots
zfs list -t snapshot

# Roll back to snapshot
zfs rollback tank/dataset@snapshot1

# Destroy snapshot
zfs destroy tank/dataset@snapshot1

# Send/receive snapshot
zfs send tank/dataset@snap1 > backup.zfs
zfs receive tank/backup < backup.zfs

ZFS Tuning

# Set ARC size
echo "1073741824" > /sys/module/zfs/parameters/zfs_arc_max

# Set sync behavior
zfs set sync=disabled tank/dataset

# Set recordsize
zfs set recordsize=1M tank/dataset

# Set primary cache
zfs set primarycache=all|metadata|none tank/dataset

Performance Monitoring

I/O Statistics

# View I/O stats
zpool iostat -v tank 1

# Detail history
zpool history tank

# Device statistics
zpool get all tank

# Cache hit ratios
arc_summary.py

Health Monitoring

# Check pool health
zpool status -x

# View errors
zpool events

# Check resilver progress
zpool status -v tank

# Pool performance
zpool upgrade -v

Advanced Configuration

Dataset Inheritance

# Set inheritable property
zfs set compression=lz4 tank

# Override inheritance
zfs set compression=gzip tank/dataset

# Check effective value
zfs get -s local,inherited,default compression tank/dataset

Special Device Classes

# Add special vdev
zpool add tank special mirror /dev/nvme0n1 /dev/nvme1n1

# Configure allocation
zfs set special_small_blocks=32K tank

# Add SLOG device
zpool add tank log mirror /dev/nvme2n1 /dev/nvme3n1

Encryption

# Create encrypted dataset
zfs create -o encryption=on -o keylocation=prompt -o keyformat=passphrase tank/secure

# Load key
zfs load-key tank/secure

# Change key
zfs change-key tank/secure

# Unload key
zfs unload-key tank/secure

References

  • Based on OpenZFS 2.2
  • Compatible with Linux, FreeBSD, and other Unix-like systems
  • For detailed performance tuning, consult the OpenZFS documentation
0 Comments for this cheatsheet. Write yours!