ZFS Command Reference

Pool Management (ZPOOL Commands)

CommandDescriptionExample Usage
zpool createCreates a new ZFS storage pool.zpool create mypool /dev/sda
zpool destroyDestroys an existing pool. This action is irreversible.zpool destroy mypool
zpool statusDisplays the status of all ZFS pools and their associated devices.zpool status
zpool listLists all active pools with their basic properties.zpool list
zpool addAdds a new device to an existing pool.zpool add mypool /dev/sdb
zpool removeRemoves a device from an existing pool.zpool remove mypool /dev/sdb
zpool scrubInitiates a scrub to verify data integrity and correct errors if necessary.zpool scrub mypool
zpool importImports an existing pool.zpool import mypool
zpool exportExports a pool, making it unavailable for use on the current system.zpool export mypool
zpool upgradeUpgrades the pool to the latest ZFS version.zpool upgrade mypool
zpool historyDisplays a history of all operations performed on the pool.zpool history mypool
zpool iostatShows input/output statistics for each pool.zpool iostat mypool

Dataset Management (ZFS Commands)

CommandDescriptionExample Usage
zfs createCreates a new dataset within a pool.zfs create mypool/mydataset
zfs destroyDestroys a dataset. This action is irreversible.zfs destroy mypool/mydataset
zfs listLists all datasets in a pool along with properties such as used and available space.zfs list
zfs getDisplays specific properties of datasets.zfs get compressratio mypool/mydataset
zfs setSets a property for a dataset.zfs set compression=lz4 mypool/mydataset
zfs mountMounts a dataset.zfs mount mypool/mydataset
zfs unmountUnmounts a dataset.zfs unmount mypool/mydataset
zfs renameRenames a dataset.zfs rename mypool/mydataset mypool/newdataset
zfs cloneCreates a writable clone of a snapshot.zfs clone mypool@mysnapshot mypool/myclone
zfs promotePromotes a clone to a full dataset, allowing it to be modified independently.zfs promote mypool/myclone

Snapshot Management

CommandDescriptionExample Usage
zfs snapshotCreates a snapshot of a dataset or volume.zfs snapshot mypool/mydataset@mysnapshot
zfs list -t snapshotLists all snapshots in the system.zfs list -t snapshot
zfs destroyDestroys a snapshot. This action is irreversible.zfs destroy mypool/mydataset@mysnapshot
zfs rollbackRolls back a dataset to a specific snapshot.zfs rollback mypool/mydataset@mysnapshot
zfs sendSends a snapshot to another location, usually for backup purposes.zfs send mypool/mydataset@mysnapshot > /backup/mysnapshot
zfs receiveReceives a snapshot from a send operation.zfs receive mypool < /backup/mysnapshot

Performance Tuning

CommandDescriptionExample Usage
zfs set atime=offDisables access time updates, improving performance for certain workloads.zfs set atime=off mypool/mydataset
zfs set recordsizeSets the record size for a dataset, which can be adjusted to optimize performance.zfs set recordsize=128K mypool/mydataset
zfs set compressionEnables compression for a dataset, improving space efficiency.zfs set compression=lz4 mypool/mydataset
zfs set dedup=onEnables deduplication, though it can impact performance.zfs set dedup=on mypool
zfs set sync=disabledDisables synchronous writes, which can improve performance but may risk data loss in the event of a crash.zfs set sync=disabled mypool/mydataset
zpool iostatDisplays I/O statistics, useful for monitoring performance.zpool iostat mypool
zpool set cachefileConfigures the location of the ZFS pool cache to improve performance for multiple pools.zpool set cachefile=/etc/zfs/zpool.cache mypool

Backup and Recovery

CommandDescriptionExample Usage
zfs sendSends a snapshot to another location for backup.zfs send mypool/mydataset@mysnapshot > /backup/mysnapshot
zfs send -iSends an incremental snapshot (only the changes since the last snapshot).zfs send -i mypool@oldsnapshot mypool@newsnapshot > /backup/incremental
zfs receiveReceives a snapshot from a zfs send operation.zfs receive mypool < /backup/mysnapshot
zpool importImports a pool from another system, typically used in recovery scenarios.zpool import mypool
zpool exportExports a pool so it can be imported on another system.zpool export mypool
zpool scrubInitiates a scrub to verify data integrity and correct errors.zpool scrub mypool

Troubleshooting

CommandDescriptionExample Usage
zpool statusDisplays the status of the pool and identifies any errors or degraded devices.zpool status
zpool clearClears error counts and resumes normal operation after a device failure.zpool clear mypool
zfs list -oDisplays dataset properties to help diagnose issues.zfs list -o name,used,available
zpool iostatProvides I/O statistics, which can help identify performance bottlenecks.zpool iostat mypool
zpool eventsDisplays events related to the ZFS pool, such as device failures or errors.zpool events
zdbZFS debugger for advanced troubleshooting.zdb -e mypool