The ZFS Goodness

by Ostatic Staff - Nov. 06, 2013

Talk to anyone about FreeBSD long enough and you'll hear mention of ZFS being one of the major benefits of the system, because of all the ZFS goodness. So, what exactly does ZFS bring that makes it such an attractive feature? Quite a bit, as it turns out, and it keeps getting better.

Before getting started on the benefits of ZFS, it should me mentioned that ZFS is supported on Linux, Illumos, and even Mac OS X. My personal experience working with ZFS comes from FreeBSD, where it has been available since 2007. I can't speak to the stability on other platforms, but on FreeBSD it is rock solid and has been production ready for years.

The features of ZFS are mostly centered around data protection and administration. When I write a file to a drive, I'm expecting to be able to get that same file back again, in the exact same state that it was when I wrote it. Unfortunatly, spinning rust hard drives are notorious for being unreliable, so much so that I never put just one in a server, there are always at least two in a RAID 1 mirror. ZFS addresses this issue by including a checksum of each block of data written for the entire filesystem. By having the checksum, and checking it each time a block of data is accessed, ZFS can tell if the data has been altered or corrupted. Once ZFS is aware of an issue, there are a few ways that it can automatically correct the problem, depending on how the hardware is configured.

For example, if you have a pair of disks as mentioned above, ZFS can use the disks in it's own internal RAID system, and automatically pull the correct data off the mirror. Or, if you use ZFS's ability to automatically create multiple copies of all data written to disk, ZFS will simply pull one of the known good copies and replace the damaged block. ZFS is doing all of this behind the scenes, protecting your data from corruption and loss.

The other part of ZFS goodness is management. ZFS is truely an enterprise grade filesystem. It can address twice as many files as anyone would ever need (it's a 128bit filesystem), and it includes a set of tools to work with the data to provide recovery and backup options. In my experience working with FreeBSD jails, each jail would have its own ZFS filesystem, and I would use the ZFS snapshot feature to freeze the state of a running jail, and run a series of pipes to send the snapshot to tar to create a gzipped tarball, and then on to SSH which would send the tarball off across the WAN for safe storage off site. The snapshot could then be imported into another FreeBSD system with a similar configuration and the jail restored on the remote machine.

Snapshots can also be used to quickly clone a filesystem in ZFS, and of course ZFS supports automatic compression and deduplication, assuming your machine can support the additional processing and storage loads. As alluded to previously, ZFS also acts as a volume manager, managing access to multiple disks and slicing up the storage as required.

ZFS is a complex system, but it is chock full of goodness normally only found in proprietary SANs. A properly configured FreeBSD machine loaded up with fast disks can give any SAN a run for its money, and provide the peace of mind that comes with knowing you can recreate the environment with open source tools and commodity hardware.