ZFS Cheatsheet

Create a RAID 1 style file system across two devices:

zpool create tank mirror /dev/sdb /dev/sdc

Create a RAIDZ2 file system with all the features:

zpool create -f tank -o ashift=12 raidz2 /dev/sda /dev/sdb /dev/sdc /dev/sdd
zfs set compression=lz4 tank
zfs set xattr=sa tank
zfs set acltype=posixacl tank
zpool set autoexpand=on tank

Add another pair of mirrored drives to create an array similar to RAID 10:

zpool add tank mirror /dev/sdd /dev/sde

Display information about the file system:

zpool status
zpool list
zpool list -v
zfs list
zfs list -t all
zfs get all

Disable a drive:

zpool offline tank /dev/sdj

Replace an active drive:

zpool replace -f tank /dev/sds /dev/sdt

Scrub an array:

zpool scrub tank

Enable autoexpand for a zpool (allows growing arrays by replacing drives with larger models):

zpool set autoexpand=on tank

Enable file system compression:

zfs set compression=lz4 tank

Create a new file system:

zfs create tank/partition1

Remove a drive, even if resilvering

zpool detach tank sdc

Clear ZFS info from a drive

zpool labelclear /dev/sdt

Remove a drive from a mirror of sdc+sdd, then attach a new drive sde

zpool detach tank sdc
zpool attach -f tank sdd sde

Remove a drive (sdx) from a RAID-Z2, then attach a new drive (sdy)

zpool offline tank sdx
zpool replace tank sdx sdy