ZFS command line reference (Cheat sheet)

Pool Related Commands

# zpool create datapool c0t0d0Create a basic pool named datapool
# zpool create -f datapool c0t0d0Force the creation of a pool
# zpool create -m /data datapool c0t0d0Create a pool with a different mount point than the default.
# zpool create datapool raidz c3t0d0 c3t1d0 c3t2d0Create RAID-Z vdev pool
# zpool add datapool raidz c4t0d0 c4t1d0 c4t2d0Add RAID-Z vdev to pool datapool
# zpool create datapool raidz1 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0Create RAID-Z1 pool
# zpool create datapool raidz2 c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0Create RAID-Z2 pool
# zpool create datapool mirror c0t0d0 c0t5d0Mirror c0t0d0 to c0t5d0
# zpool create datapool mirror c0t0d0 c0t5d0 mirror c0t2d0 c0t4d0disk c0t0d0 is mirrored with c0t5d0 and disk c0t2d0 is mirrored withc0t4d0
# zpool add datapool mirror c3t0d0 c3t1d0Add new mirrored vdev to datapool
# zpool add datapool spare c1t3d0Add spare device c1t3d0 to the datapool
## zpool create -n geekpool c1t3d0Do a dry run on pool creation

Show Pool Information

# zpool status -xShow pool status
# zpool status -v datapoolShow individual pool status in verbose mode
# zpool listShow all the pools
# zpool list -o name,sizeShow particular properties of all the pools (here, name and size)
# zpool list -Ho nameShow all pools without headers and columns

File-system/Volume related commands

# zfs create datapool/fs1Create file-system fs1 under datapool
# zfs create -V 1gb datapool/vol01Create 1 GB volume (Block device) in datapool
# zfs destroy -r datapooldestroy datapool and all datasets under it.
# zfs destroy -fr datapool/datadestroy file-system or volume (data) and all related snapshots

Set ZFS file system properties

# zfs set quota=1G datapool/fs1Set quota of 1 GB on filesystem fs1
# zfs set reservation=1G datapool/fs1Set Reservation of 1 GB on filesystem fs1
# zfs set mountpoint=legacy datapool/fs1Disable ZFS auto mounting and enable mounting through /etc/vfstab.
# zfs set sharenfs=on datapool/fs1Share fs1 as NFS
# zfs set compression=on datapool/fs1Enable compression on fs1

File-system/Volume related commands

# zfs create datapool/fs1Create file-system fs1 under datapool
# zfs create -V 1gb datapool/vol01Create 1 GB volume (Block device) in datapool
# zfs destroy -r datapooldestroy datapool and all datasets under it.
# zfs destroy -fr datapool/datadestroy file-system or volume (data) and all related snapshots

Show file system info

# zfs listList all ZFS file system
# zfs get all datapool”List all properties of a ZFS file system

Mount/Umount Related Commands

# zfs set mountpoint=/data datapool/fs1Set the mount-point of file system fs1 to /data
# zfs mount datapool/fs1Mount fs1 file system
# zfs umount datapool/fs1Umount ZFS file system fs1
# zfs mount -aMount all ZFS file systems
# zfs umount -aUmount all ZFS file systems

ZFS I/O performance

# zpool iostat 2Display ZFS I/O Statistics every 2 seconds
# zpool iostat -v 2Display detailed ZFS I/O statistics every 2 seconds

ZFS maintenance commands

# zpool scrub datapoolRun scrub on all file systems under data pool
# zpool offline -t datapool c0t0d0Temporarily offline a disk (until next reboot)
# zpool onlineOnline a disk to clear error count
# zpool clearClear error count without a need to the disk

Import/Export Commands

# zpool importList pools available for import
# zpool import -aImports all pools found in the search directories
# zpool import -dTo search for pools with block devices not located in /dev/dsk
# zpool import -d /zfs datapoolSearch for a pool with block devices created in /zfs
# zpool import oldpool newpoolImport a pool originally named oldpool under new name newpool
# zpool import 3987837483Import pool using pool ID
# zpool export datapoolDeport a ZFS pool named mypool
# zpool export -f datapoolForce the unmount and deport of a ZFS pool

Snapshot Commands

# zfs snapshot datapool/fs1@12jan2014Create a snapshot named 12jan2014 of the fs1 filesystem
# zfs list -t snapshotList snapshots
# zfs rollback -r datapool/fs1@10jan2014Roll back to 10jan2014 (recursively destroy intermediate snapshots)
# zfs rollback -rf datapool/fs1@10jan2014Roll back must and force unmount and remount
# zfs destroy datapool/fs1@10jan2014Destroy snapshot created earlier
# zfs send datapool/fs1@oct2013 &gt /geekpool/fs1/oct2013.bakTake a backup of ZFS snapshot locally
# zfs receive anotherpool/fs1 &lt /geekpool/fs1/oct2013.bakRestore from the snapshot backup backup taken
# zfs send datapool/fs1@oct2013 | zfs receive anotherpool/fs1Combine the send and receive operation
# zfs send datapool/fs1@oct2013 | ssh node02 “zfs receive testpool/testfs”Send the snapshot to a remote system node02

Clone Commands

# zfs clone datapool/fs1@10jan2014 /clones/fs1Clone an existing snapshot
# zfs destroy datapool/fs1@10jan2014Destroy clone