OS Hacking and more.

7.14.2008

ZFS and OS X: Does it work?


With the recent announcement of the next iteration of Mac OS, 10.6 Snow Leopard, Apple has taken a giant leap of faith, providing full ZFS support for use in its server OS. In anticipation of this functionality, I tested the most recent ZFS support infrastructure for OSX, with some surprising results.

In 10.5, Apple provided read-only support for ZFS, allowing users to import and mount zfs pools and volumes, but not modify them. Apple developers are offered the opportunity to download a bleeding edge patch to enable read-write support. This patch, however, is only for 10.5.1 and will not run in any other system(new or old). Fortunately, developers at zfs.macosforge.org have persisted in the improvement of ZFS support on OSX. Their system certainly provides greater functionality than Apple's, but the question is, how much functionality is that?

First the setup
Using the latest binary (build 117), Installation is straightforward and relatively simple..
I'm using 10.5.2.
I use two usb drives for a zfs raid volume...one is 4.1gb, the other is 4.2gb
I performed Sun's classic ZFS function test: Does it smash?
From start to finish:
1) Create a zfs pool with raidz across the drives:


$ sudo -s
$ zpool create zfpool raidz disk[X] disk[Y]



2) Create a zfs volume inside


$ zfs create zfpool/zvol



3) Make some files


$ cd /Volumes/zfpool/zvol
$ touch qq
$ mkdir direct
$ echo " a lot of text" > gibberish.txt


Perhaps copy some larger files here as well...movies are good...You can play them while doing damage
4) Begin chaos: pull out one of the drives
5) Check the status:
You will notice that the status has not changed; zfs in solaris has daemons updating it constantly, whereas in OSX it will need to be manually updated


$ zpool status
$ zpool clear zfpool
$ zpool scrub zfpool
$ zpool status


Now one of the drives will show Removed and the health will be Degraded, shouldn't be a problem for raidz
6)Damage Assessment


$ cd /Volumes/zfpool/zvol
$ ls



files should be intact
#Assess other file function: play a movie!
7) Return to calm for a moment: reconnect the other drive and


$ zpool clear zfpool
$ zpool scrub zfpool
$ zpool status



#everything should be online and healthy
#you can do the same test with the other drive
8)More Damage! unplug both drives and plug them in different ports...
Check the status(5) and Assess damage again...(6)
Stuff should still work...note how the device ids change but the health doesn't.
-----------------------------------------
All in all, OSX did pretty well with ZFS in these trials, which are analogous in many ways to the sledgehammer trials that Sun does: setup ZFS on stage and destroy the harddisks sequentially while watching the filesystem repair itself.

More specifically, the data on the ZFS volume survived the various trials, though the fact that the zpool status had to be manually updated was a pain. Still, looks like the ZFS implementation is functional enough to be used on a small scale. ZFS in Snow Leopard will probably be safe for enterprise use, seeing as current support passes basic data safety tests: Videos played fine and the files never vanished through thick and thin.
------------------------------------------
Now for the bad news:
I was able to confuse ZFS at some point such that it would not reattach a removed volume...this is where OSX is still sticky....
when reconnected the drive would claim to be busy and I couldn't perform a zpool replace...
so while my data was intact, I couldn't restore the raid to its state of happiness from OSX--I had to use Solaris.
Also, the ZFS implementation for OSX is not the latest version of ZFS, so ZFS volumes created in newer Solaris builds aren't importable or usable. This was sad :(

2 comments:

Rajesh Gupta said...

Like NTFS, it may be a licensing issue that OSX can not modify ZFS data.

Anand Gupta said...

This is probably not the case, as Mac OS X 10.6 Snow Leopard Server has ZFS support(read-write) out of the box.