Mac OS X,  Mac OS X Server,  Xsan

Quick Tips on ZFS

ZFS is coming to the Mac, according to the Apple website.  But it isn’t here yet.  In the meantime, you can learn a lot about some upcoming technology without ever downloading a single trial copy of Mac OS X by using the hobbled ZFS implementation on Leopard or a full version hosted on OpenSolaris, or another OS that has full ZFS support.  ZFS on most *nix systems follows the same command line structures for the most part.  For example, running the following command will show you each of your ZFS mount points and if you can’t actually write to any volumes (as is the case with 10.5.x), the OS will let you know:

zfs list

If you have mount points, then you’ll see output similar to the following:

NAME   USED  AVAIL  REFER  MOUNTPOINT

FCS_DB   212G  124G   336G  /Volumes/FCS/FCS_DB

FCS_BAK   234G  100G   334G  /Volumes/FCS/FCS_BAK

This simply shows that there are two volumes available through ZFS, the size, etc.  The building blocks for an actual volume for ZFS is a zpool.  The commands in the rest of this article are dedicated to zpools, I’ll follow up with another on more in depth zfs management and snapshots at a later date.  The zpool command can then be used to create, modify and delete storage pools through ZFS, providing a better way to access RAID5-like features without the same overhead and with greater granularity in control.  The zpool command can then be used with a status option in order to see the status of your pools as well as read, write and checksum statistics:
zpool status
You can also constrain the information that is displayed with the status subcommand.  For example, you can grep a specific disk to verify whether it is a part of one of your pools or, to show all disks in all zpools:
zpool status | awk ‘$1 ~/^c[0-9]/ {print $1}’ | sort
You can also use the zpool command to see stats about the pool using the iostat subcommand (again, grep + awk to constrain output):
zpool iostat
You can also use iostat with a -v to get really detailed statistics.  But that’s about as easy as it gets.  From here, you can actually begin to create mirrors:
zpool create pool mirror (and then the disks/devices that would make up the mirror)
Or you can create a zpool with a single instance of parity (similar to a RAID5):
zpool create pool raidz1 (and then the disks/devices that would make up the RAID)
It’s also possible to create a double instance of parity, similar to how RAID6 works:
zpool create pool raidz2 (and then the disks/devices that would make up the RAID)
Once created, the zpool add subcommand will allow you to add more storage into the pool at a later date.  And of course, adding a spare is fairly straight forward, take the above commands, add the word spare after the disks that make up the mirror or parity-added zpool and then follow it with the word spare and then the disks that would be acting as your spares.  You can also carve out a disk specifically for caching, a potentially great use for your SSD media if you have a Nehalem Xserve, by simply following the command that you would use to create a given pool with the word cache and then the actual disk label to be used for caching.
Pools can also be imported or exported from a system using the import and export subcommands respectively.  ZFS has different versions and so in addition to an import or an export, you may find the need to occasionally upgrade a pool, which can be done using the upgrade subcommand.  In the following command, we look at upgrading the pools concurrently:
zpool upgrade -a
Zpools have a number of properties.  Some, such as capacity, size and health are read only.  However, others can be assigned a value by using the set subcommand of zpool.  These include the autoreplace (which replaces a removed device with another one), cachefile (provides control over where config data is located), failmode (what to do if the target storage becomes inaccessible), etc.
Troubleshooting tools specific to zpools are also available, such as the zpool scrub sub-command, which just looks at the checksums and repairs any inconsistencies.
Once you are comfortable with zpools and the commands that you use to manage them let’s take a look at using the actual zfs command.  Let’s take those zpools and create a file systems:

zfs create nameofmyzpools /MyVolume

Now let’s delete that file system:

zfs destroy nameofmyzpools/MyVolume

Finally, you’ll likely want to tell a compelling story of what has happened to your pools from time-to-time and so ZFS provides a history subcommand to the zpool command for doing so.  Overall, these tools provide a pretty good way of managing ZFS, with syntax only varying across platforms when the actual features have been deprecated or there are compile-time operations that specify another use case.  The stability of ZFS on other platforms seems pretty good (still haven’t seen a failure) and the speed seems similar to other file systems employed by Mac OS X.