After years dealing with storage and storage system, I encountered surprise when I met ZFS. This software implementation by Oracle is so simple and robust in terms of what it can do versus flexibility of use, previously I never had a chance to manage something that robust with so small amount of effort, I have compiled my cheat sheet with some examples – may be useful to you!

Multiple types of RAID redundancy possible.

RAIDZ1 = N-Disks – 1 ; For example, 3 disk X 1GB = 3GB ; then RAID is 3GB – 1GB = 2GB of usable space
RAIDZ2 = N-Disks – 2 ; For example, 4 disks X 1GB = 4GB ; then RAID is 4GB – 2GB = 2GB of usable space
RAIDZ3 = N-Disks – 3 ; For example, 4 disks X 1GB = 4GB, then RAID is 4GB – 3GB = 1GB of usable space
RAID10 = Double parity with stripping, meaning – 4 disks x 1GB = 4GB, 2 Mirrors = 2GB, can survive one failure in each mirror
Mirror = classic parring

# To create ZFS pool
zpool create datapoolname raidtype /dev/sdb /dev/sdc

# To inspect ZFS pool
zpool list
zpool status
zfs list
zpool get all datapoolname

# To expand ZFS pool
zfs add datapool raidtype /dev/sdd /dev/sde

# To remove the ZFS pool or dataset
zfs destroy -f datapool
zfs destroy -f datapool/datasetname

# To create a dataset
zfs create datapool/datasetname

# Change ZFS mount point
zfs set mountpoint=/zfsmountpoint datapool/datasetname

# Create ZFS quota and reservation, quota will make sure that only % amount of space can be consumed by dataset, reservation will take the % amount of space from parent pool
zfs set quota=1G datapool/datasetname
zfs set reservation=1G datapool/datasetname

# Creating different RAID types

ZFS RAID levels


# ZFS reference by Oracle
http://www.oracle.com/technetwork/systems/hands-on-labs/s11-intro-zfs-1408637.html

# Creating ZFS snapshots
zfs snapshot datapool/dataset@snapshotname

# Deleting ZFS snapshots
zfs destroy datapool/dataset@snapshotname

# Listing ZFS snapshots
zfs list -t snapshot

# Mounting ZFS snapshots
mount -t zfs datapool/dataset@snapshotname /mnt/snapshot

# We can also rollback to the specific snapshot
zfs rollback datapool/dataset@snapshotname

# ZFS snapshots can be sent and received between systems
zfs send DATA/dataset1@snapshot2 | ssh vm02 “zfs recv zfsset/dataset1”

# To send an incremental stream of snapshots
zfs send -I DATA/dataset1@snapshot1 DATA/dataset1@snapshot5 | ssh vm02 “zfs recv zfsset/dataset1”

# To calculate the size of the snapshot that is going to be sent
zfs send -nv -I “${sourcepool}@${yesterday}” “${sourcepool}@${today}”

# To use mbuffer to speed up the snapshot send/receive

– receiver side: mbuffer -s 128k -m 1G -I 9090 | zfs receive data/filesystem &
– sender side: zfs send -i data/filesystem@1 data/filesystem@2 | mbuffer -s 128k -m 1G -O 10.0.0.1:9090

# To retrieve properties from the datapool or dataset we can do following
zfs get propertyname datapool/dataset
zfs get all datapool/dataset
zfs get compressratio ; du -sh .
zpool get dedupratio

# quick one
for i in $(zfs list | awk ‘{ print $5 }’ | grep -v MOUNTPOINT); do zfs get dedup $i && zfs get compression $i; done

# To set the property
zfs set compression=lz4 datapool/dataset
zfs set dedup=on datapool/dataset

# Configure file system to support ACLs
zfs set acltype=posixacl datapool/dataset

# To present ZFS as a block device for iscsi we have to create it as a volume, it’s gonna be represented as /dev/zvol/
zfs create -V size datapool/dataset