ZFS Notes

Example pool name is "banana"

Favourite zfs Commands

This will mount the new fs on /banana:

 zpool create banana mirror c0d0 c1d1

Mount the new fs somewhere else:

 zpool create -m /local/mymountpoint banana mirror c0d0 c1d1
 zfs list
 zfs create banana/banana1
 zfs create banana/banana2
 zfs set mountpoint=/users banana/banana1
 zfs set quota=100g banana/banana1
 zpool status banana

Snapshots

Make a timestamped snapshot of the entire zone pool:

 /usr/sbin/zfs snapshot banana@`/bin/date +'%FT%R'`

this will result in a snapshot e.g. banana@2009-06-30T1250. Files in the snapshot can be accessed at /banana/.zfs/snapshot/2009-06-30T1250/ .

List all snapshots:

 zfs list -r

Send a snapshot to another system:

 zfs send zone@2009-04-29T1015 | ssh otherhost "/usr/sbin/zfs receive newpool/subpool"

mount usb drives

iostat -En

  1. find the USB drives zpool create banana raidz c0t0d0 c4t0d0
  2. may have to use create -f if they have anything on them

scrub

A thing *like* fsck that can run while the system is up:

 zpool scrub banana

More info: google "Checking ZFS Data Integrity"

If a zfs disk in a pool gets out of sync, e.g. removed and re-inserted, "zpool online" may not online it, and "zpool replace" may refuse to add it back in to the pool, saying "cannot replace, c0t1d0s3 is busy" or "is part of active zfs pool". Erase the disk and then the replace will work and the drive will start up a resilver / scrub.

add zfs swap

  zfs create -V 40gb export/swap
  /usr/sbin/swap -a /dev/zvol/dsk/export/swap
 (don't forget to add it to /etc/vfstab)

ZFS Snapshot Script

Here is a script for backing up snapshots, based on %Y-%W-%w (Year, Week of Year, Day number in week).

ZFSSnapshotBackup

References