openzfsonosx / zfs

OpenZFS on OS X
https://openzfsonosx.org/
Other
824 stars 72 forks source link

Launchd: no pools available to import #802

Closed fskaeh closed 2 years ago

fskaeh commented 2 years ago

Machine: Mac Mini M1 (16GB RAM) OS: MacOS 12.6 zpool version: zfs-macOS-2.1.0-1

Hi, I'm facing a situation which leaves me baffled. It seems like zpool import -a -d /var/run/disk/by-id refuses to work when started by Launchd. I installed zfs via hombrew, so it automatically set up some services to import pools on boot, but the org.openzfsonosx.zpool-import.plist service can't find my zpools. This service is really basic and only runs the command I pasted above. If I trigger the service manually, the log file in /private/var/log shows no pools available to import. That service is in /Library/LaunchDaemons and I haven't tampered with it either. The funny thing is that if I just open a terminal and run sudo su - zpool import -a -d /var/run/disk/by-id (copypasting the command directly from LaunchControl). Then my zpool is imported without any issue. This is also not due to a delay in the disks becoming available after boot, because if I import my pool manually, then export it, and then run the service, it still refuses to work. It seems like when the zpool import command is run by launchd, there's some environment discrepancy which doesn't allow it to find my pool. Has anyone ever faced this issue before?

lundman commented 2 years ago

I think this is related to "Full Disk Access", and that "bash" needs to be given it to work. You'd think giving FDA to zpool would work, but previous tests seem to indicate it wasn't enough. I think it was discussed on the forums.

fskaeh commented 2 years ago

Ooooh okay I have seen some comments about this in other issues but did not realize it may apply here! I will try and report back, thanks!

fskaeh commented 2 years ago

Happy to report that this indeed did the trick. Thanks for the tip!