macOS mount to openBSD NFS shares

I have been using Vagrant & Virtualbox for a long time but recently I’ve run into something which I believe is a bug somewhere betweek macOS, nfsd, Virtualbox & openBSD.


The issue started after upgrading OSX to macOS Sierra, Virtualbox to 5.1.8 & Vagrant to 1.6.8. What were the issue and the facts?

Some of the things I’ve tried:

There are a lot of bugs regarding compatibility of Vagrant and Virtualbox. Among them, Vagrant <1.8.6 seem to support Virtualbox 5.0.18 but it doesn’t. I was getting a message telling me that I need to install a Virtualbox version >4.x when I’ve already had installed 5.0.18.

Then I tried to upgrade Virtualbox to 5.0.20 and the problem came up again in its full extend. It seems that something has changed around 5.0.18–5.0.20 that broke the compatibility between Virtualbox, nfsd and macOS. There was no hope. Then a colleague suggested to try something like reversing the NFS shares. This is how I tried that: /Users/username/shared_dir nfs resvport
/home/vagrant/shared_dir/ -network=192.168.10 -mask= -alldirs -mapall=<your_username_here>
rcctl enable portmap mountd nfsd
rcctl set nfsd flags -tun 4
# after making changes to the export file
rcctl reload mountd
mount -a

And finally I was able to share the directory I wanted from openBSD to macOS.

But I had a problem with permissions on macOS which was that I couldn’t read or write to the share. I created a user with the same username in openBSD and assigned him the same uid and gid with macOS. I don’t know If there are arguments to add uid/gid to a user in a simple command (e.g. adduser) but as far as this worked I’m fine:

# to get the id info of the user, do this both in openBSD and macOS.
# in my case they were uid=502, gid=20
id my_username
# create a user in openBSD with the same name as in macOS
useradd my_username
# assign uid and gid
usermod -u 502 my_username
usermod -g 20 my_username

and everything from this point worked perfectly!