ZFS Cheat Sheet

Pool Management

CommandDescriptionExample
zpool createCreate a new ZFS poolzpool create mypool /dev/sda
zpool destroyDestroy a ZFS pool (irreversible)zpool destroy mypool
zpool statusCheck the status of pools and deviceszpool status
zpool listList all active poolszpool list
zpool addAdd a device to an existing poolzpool add mypool /dev/sdb
zpool removeRemove a device from the poolzpool remove mypool /dev/sdb
zpool scrubStart a scrub for data integrityzpool scrub mypool

Dataset Management

CommandDescriptionExample
zfs createCreate a new datasetzfs create mypool/mydataset
zfs destroyDestroy a datasetzfs destroy mypool/mydataset
zfs listList all datasetszfs list
zfs setSet a property on a datasetzfs set compression=lz4 mypool/mydataset
zfs getGet properties of a datasetzfs get all mypool/mydataset
zfs renameRename a datasetzfs rename mypool/oldname mypool/newname

Snapshot Management

CommandDescriptionExample
zfs snapshotCreate a snapshotzfs snapshot mypool/mydataset@snap1
zfs destroyDestroy a snapshotzfs destroy mypool/mydataset@snap1
zfs rollbackRoll back to a snapshotzfs rollback mypool/mydataset@snap1
zfs list -t snapshotList all snapshotszfs list -t snapshot

Backup and Replication

CommandDescriptionExample
zfs sendSend a snapshotzfs send mypool/mydataset@snap1 > /backup/snap1
zfs receiveReceive a snapshotzfs receive mypool < /backup/snap1
zfs send -iSend an incremental snapshotzfs send -i snap1 snap2 > /backup/incr

Performance Tuning

CommandDescriptionExample
zfs set atime=offDisable access time updateszfs set atime=off mypool/mydataset
zfs set recordsizeSet the record size for a datasetzfs set recordsize=128K mypool/mydataset
zfs set compressionEnable compressionzfs set compression=lz4 mypool/mydataset

Troubleshooting

CommandDescriptionExample
zpool statusCheck pool status for errorszpool status
zpool clearClear errors from a poolzpool clear mypool
zpool scrubScrub the pool to repair errorszpool scrub mypool
zpool iostatShow I/O stats for the poolzpool iostat mypool
zdbZFS debugger for advanced troubleshootingzdb -e mypool

Common ZFS Properties

PropertyDescriptionExample
compressionEnables compression (e.g., lz4, gzip)zfs set compression=lz4 mypool
dedupEnables deduplicationzfs set dedup=on mypool
syncConfigures sync behaviorzfs set sync=disabled mypool/mydataset
atimeControls access time updateszfs set atime=off mypool/mydataset
quotaSets a dataset quotazfs set quota=10G mypool/mydataset

Best Practices

Regular Scrubbing: Scrub your pools regularly to ensure data integrity:

zpool scrub mypool

Snapshots for Backup: Take regular snapshots for backups:

zfs snapshot mypool/mydataset@snap1

Compression: Enable compression to save space with minimal performance impact:

zfs set compression=lz4 mypool/mydataset