MacOS – Using SSHFS with launchd

filesystemlaunchdmacosmount

I have a Raspberry Pi I want to automount on my Desktop (Yosemite 10.10.1). I've installed OSXFuse (with the MacFuse option) and SSHFS both from https://osxfuse.github.io/. I'm using the password method for now and will establish certificates after I get this problem solved.

The following command works fine from Terminal:

/bin/mkdir /Volumes/RaspPi ; echo "mypassword" | /usr/local/bin/sshfs myuserid@192.168.8.16:/ /Volumes/RaspPi -o workaround=rename -o password_stdin -o allow_other -o defer_permissions -ovolname=RaspPi

Placing it into a launchd plist worked the first day. The volume would get mounted and if I ejected it, launchd would remount it. But subsequently it has failed with the error:

kernel[0]: OSXFUSE: user-space initialization failed (4)

The RaspPi mountpoint gets created in /Volumes, but the volume doesn't get mounted.

The plist contains these lines:

    <string>bash</string>
    <string>-c</string>
    <string>/bin/mkdir /Volumes/RaspPi ; echo "mypassword" | /usr/local/bin/sshfs myuserid@192.168.8.16:/ /Volumes/RaspPi -o workaround=rename -o password_stdin -o allow_other -o defer_permissions -ovolname=RaspPi</string>

I reviewed a lot of discussion about OSXFuse working via Terminal and not in launchd, but none of the solutions dealt with "initialization failed (4)". They all seemed to deal with a socket problem and error 57. I tried a few of those solutions, but they did not help.

Any suggestions?

Best Answer

I got it fixed by adding

<key>AbandonProcessGroup</key>
<true/>

More info about it can be found here OSX run script to mount sshfs at login with a plist file