ZFS

From StdOut

ZFS is a combined file system and logical volume manager designed by Sun Microsystems. ZFS is scalable, and includes extensive protection against data corruption, support for high storage capacities, efficient data compression, integration of the concepts of filesystem and volume management, snapshots and copy-on-write clones, continuous integrity checking and automatic repair, RAID-Z, native NFSv4 ACLs, and can be very precisely configured. (source: Wikipedia)

Pool

Create

sudo zpool create testpool -o ashift=12 raidz1 /dev/disk/by-id/ata-ST2000DM001-1CH164_W1E5ETF9 /dev/disk/by-id/ata-ST2000DM001-1CH164_Z1E68GLR /dev/disk/by-id/ata-ST2000DM001-1CH164_Z1E6CQPW
sudo zpool status
Make sure that you create your pools such that the vdevs have the correct alignment shift for your storage device’s size. if dealing with flash media, this is going to be either 12 (4K sectors) or 13 (8K sectors). http://open-zfs.org/wiki/Performance_tuning

Add VDEV

zpool add mypool mirror ada2p3 ada3p3

Compression

sudo zfs set compression=lz4 testpool
sudo zfs get compression testpool
Size reduced with compression:
  • VirtualBox VM: 48G → 34G
  • Documents, photos, videos, etc: 395G → 388G

Stats

zpool iostat testpool 1
zfs get space (pool/dataset)

Scrub

zpool scrub files

Dataset

zfs list

Create

sudo zfs create testpool/test

Remove

sudo zfs destroy testpool/test (-r)

Snapshot

# Create
sudo zfs snap testpool/test@snap

# Destroy
sudo zfs destroy testpool/test@snap

# List
sudo zfs list -t snapshot

Send and receive

# local
zfs send tank/data@snap1 | zfs recv spool/ds01
# remote
zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana

Resources