Hi all,
I've created a 1-disk ZFS pool using my 2TB external hard drive, and so far I'm loving it. However, I'd like to improve the ergonomics around plugging it in and unplugging it. If I'm not mistaken, pools need to be imported if they are connected after boot, and exported before ejecting the relevant disks. Running sudo zpool import <pool> and sudo zpool export <pool> in a terminal isn't sooo unergonomic, but sometimes I just want to plug the disk in, yank one episode of Rick and Morty off it, and then unplug it.
I think I've solved the plugging in side of things with a hacky C program I wrote that listens for Apple's "DiskArbitration" events and runs zpool import -a as root whenever a new disk is connected to the system (probably overkill, and might also be subject to a race condition if zpool doesn't deem the disk ready yet). It does seem to work though. Code is here: https://github.com/michaelsproul/autozfs. What do you think of this approach? Is there a better alternative that doesn't require running yet-another daemon? The InvariantDisks daemon that comes with O3X listens for the same events, maybe they could be combined?
Regarding ejects, I think all that needs to happen is for OpenZFS to do a pool export when ejecting a disk from Finder. At the moment ejecting a stand-alone ZFS external disk unmounts the filesystem but doesn't export the pool. I think there's a slight conceptual mismatch here (because ZFS isn't like other filesystems) but we could hack something together that works for this use-case, which I imagine would be fairly common amongst home users like myself.
Anyway, thanks for reading, interested to hear your thoughts on this and any other tips and tricks you're using,
Cheers,
Michael