Anders Brownworth

Technology and Disruption

ZFS on Mac with Thunderbolt Drives

Licensing is to blame for ZFS not being more popular, particularly within the Linux world. However the open source combined filesystem / volume manager originally from Sun is coming on strong these days. While you might traditionally think of ZFS in a server context, the combination of Thunderbolt drive enclosures and the MacZFS project suddenly make for some tantalizing opportunities for the Mac user. Let's just think this through.

Thunderbolt gives you a 10Gb/s pathway to your drives which they can't come close to filling. There is also a good chance that once you have some Thunderbolt drives, you will want to add more in the future. Rather than just adding more and more volumes to your machine and splitting your data amongst them, you could use ZFS and grow a single volume as you add drives instead. Oh, and did I mention you also get the data integrity, copy on write, snapshots, continuous integrity checking and automatic repair that come with ZFS as well? I digress.

Admittedly the Thunderbolt drive options are few and far between these days but they will come. We are just starting to see Thunderbolt enclosures that allow you to snap in any old bare drive, and Thunderbolt PCIe cards can't be far off either.

So how would you format a ZFS volume? Here's a practical example.

I have a 4 drive external enclosure where drives show up as /dev/disk5, /dev/disk6, /dev/disk7 and /dev/disk8. I know this by plugging it in, turning it on and running diskutil in a terminal:

diskutil list

I partition each disk with a GPT (GUID Partition Table) rather than the standard APM. (Apple Partition Map)

diskutil partitiondisk /dev/disk5 GPTFormat ZFS %noformat% 100%
diskutil partitiondisk /dev/disk6 GPTFormat ZFS %noformat% 100%
diskutil partitiondisk /dev/disk7 GPTFormat ZFS %noformat% 100%
diskutil partitiondisk /dev/disk8 GPTFormat ZFS %noformat% 100%

Next I will create a RAID-Z out of all the second partitions on each disk. (by default, the second partition is marked ZFS on each disk - see the output of diskutil list)

zpool create Data raidz disk5s2 disk6s2 disk7s2 disk8s2

You should be left with a mounted RAID-Z volume called Data.

Lastly I'm going to disable Spotlight indexing on that volume because Spotlight is incompatible with ZFS. (Spotlight is created to be used on HFS+ (normal Mac) volumes)

mdutil -i off /Volumes/Data

So we're good to go. You can now use the volume like any other Mac volume, reading and writing as usual.

You can see how your ZFS storage pools are doing with:

zpool status

At some point, you might have a drive failure. To replace /dev/disk5, you would:

zpool offline disk5

(physically replace the disk)

zpool replace Data disk5

In the future, you also might want to add more drives to your setup. Currently you can't just add single disks to a RAID-Z to increase it's size. What you want to do to grow the filesystem is add another group of disks to create a new virtual device which ZFS will use to expand the filesystem. As a rule of thumb, you want to keep the groups of disks to similar size or you will end up using whatever set is bigger a little more than the others. To add the new disks, it is very similar to how you initially created your initial RAID-Z:

zpool add Data raidz disk9s2 disk10s2 disk11s2 disk12s2

Now notice zpool status shows you two virtual RAID-Z devices and your Data volume magically grew to twice it's size!

Additional Reading:
Mac ZFS - Getting Started
Solaris ZFS Administration Guide
ZFS Best Practices Guide

Comments (3)

Anders from Cambridge, MA

An interesting product to consider for this is the $99 Thunderbolt to 2.5 inch SATA hard drive converter.

Shawn from Lausanne, switzerland

Can you share with us What 4bay drive enclosure you are using (can it handle 4TB drives)... If if, now a year later, you have evolved your solution? Can this setup handle NetworkHomeDirectories ?.. I've heard that ZFS treats the Library/ folder poorly for OS X users?

Anders from Cambridge, MA

@Shawn - I'm using this enclosure: Icy Dock with 4 x 4TB drives. I'm not doing NetworkHomeDirectories so I can't authoritatively say, but I do use MacZFS for data volumes. While not a perfect solution, (for the Library/ reason you mention) pools are too useful to ignore.

Leave a Comment

Location: (city / state / country)
Email: (not published / no spam)

No HTML is allowed. Cookies must be enabled to post. Your comment will appear on this page after a moderator OKs it. Offensive content will not be published.

Click the banana to submit your comment.

To create links in comments:
[link:] becomes
[link:|] becomes
Notice there is no rel="nofollow" in these hrefs. Links in comments will carry page rank from this site so only link to things worthy of people's attention.