Creating a ZFS pool in a Sparseimage or DMG on OS X

Since I see regular corruption and filesystem errors on my HFS+ partitions it seemed time to give ZFS on OS X a try.

Since there are several ZFS implementations for OS X available you can choose the one you feel most confident that will work. Regardless… here is the script I wrote to automate the creation of my zpools with some data safety against bit rot and filesystem corruption (at least more than HFS+ offers).

ZFS Utils for OS X
ZFS Utils for OS X on PyPI

You can install it like this:


Zpool create usage:

And the actual creation of an image on my local system:

Zpool import usage:

Example run:

And to make it mount automatically during boot (make sure you have sudo zpool in your sudoers file as passwordless), add this to /Library/LaunchDaemons/wolph.zfs.plist.

In addition, if you want to speed it up a little with a ram drive. You can create and attach one like this:

The size is decided by the number after ram://, simply multiply the amount of megabytes you want by 2048 (in this case 4096 * 2048 = 4Gi of ram)

The X should be replaced with the disk drive you got from the hdiutil command.

Note that using a ram drive as a cache drive is a _very_ bad idea if you have L1ARC available (i.e. all except the current OS X implementation I believe), in that case there is really no point to this as you will be trading really fast memory (L1ARC) for a slower ram drive which will be used slightly differently (L2ARC).

Bookmark and Share

About Rick van Hattem

Rick van Hattem is a Dutch Internet entrepreneur and co-founder of
No comments yet.

Leave a Reply