macOS OpenZFS
I happened to have a bunch of spare SSDs with me while also running out of space on my M.2 enclosure. So I had the idea of building a quad ssd enclosure DAS.
Most of the enclosures I can find uses the same chipset from ASMedia (ASM-2464PDX), I picked the 4M2 from OWC as it has built-in cooling fans and cheaper than Terramaster.
My specs:
- OWC 4M2 thunderbolt M.2 bay
- Corsair MP600 PRO LPX 4TB x 4
Since macOS does not have native support for RAID 5 and I don’t want to pay for OWC’s softRAID, I decided to try OpenZFS.
Some history on ZFS and macOS (src):
- 2009 – Apple’s ZFS project closed. The MacZFS project continued to develop the code.
- 2013 – OpenZFS on OS X ports ZFS on Linux to OS X.
- 2013 – Official announcement of the OpenZFS project.
Getting OpenZFS
Head to OpenZFS’s GitHub release and download the .pkg that supports your current OS. For example: OpenZFSonOsX-2.3.0-Sequoia-15-arm64.pkg
It’s gonna to install some daemons and a kernel extension so you will have to restart your mac. It’s nice I don’t need to worry about disabling SIP.
Configurations
Pool/Dataset Creation
format all the drives:
you don’t have to do this if it’s freshly installed
diskutil eraseDisk free none /dev/diskX
create
zpool
:Following the recommended pool creation command line here assuming my disks are disk4 - disk7:
sudo zpool create -f -o ashift=12 \ -O compression=lz4 \ -O casesensitivity=insensitive \ -O atime=off \ -O normalization=formD \ [pool] raidz1 /dev/disk4 /dev/disk5 /dev/disk6 /dev/disk7
creating dataset (or see below for encrypted dataset):
zfs create [dataset]
change
recordsize
for datasets with big files, for example:sudo zfs set recordsize=1M mypool/photos
enable autotrim:
sudo zpool set autotrim=on [pool]
mount/unmount dataset:
sudo zfs unmount [dataset]
Dataset Encryption
enable encryption for the zpool:
sudo zpool set feature@encryption=enabled [pool]
creating encrypted dataset
sudo zfs create -o encryption=on -o keylocation=prompt -o keyformat=passphrase [dataset]
to see the encryption status of the dataset:
sudo zfs get encryption [dataset]
to (un)load the key (so you get to enter it again next time before mounting):
sudo zfs load-key -r [dataset] sudo zfs unload-key -r [dataset]
and to check key status:
sudo zfs get keystatus [dataset]
Maintenance
NO password on read/write
by default OpenZFS volumes can only be written by the root
user, to give yourself read and write access so you don’t have to type your password every time:
Click at the icon of your mounted ZFS pool on your desktop, select in the menu bar File > Get Info.
Click at the little lock icon at the bottom, type in an admin username and password.
Click at the Plus icon at the bottom on the left.
Add a your own user name or all administrators with read and write privileges.
MISC
- verify checksum and repair with:
sudo zpool scrub [pool]
- redundancy:
sudo zfs set copies=2 [dataset]
- current read/write status:
zpool iostat -v [pool]