Friday, February 22, 2013

Serving NFS to guests using VirtualBox on OS X

The other day, I was trying to setup a NFS share on my Mac that VirtualBox guests could mount.

It didn't work for a while, and then I found a server option which cleared things up.

Funny enough, the OS X manual says that there is a 'false belief that this requirement increases security', yet they left the default as 1.  Fix with the following:
# /etc/nfs.conf
nfs.server.mount.require_resv_port = 0
You'll have to create this file, it doesn't exist by default.

Then just run:
nfsd update
Then you should be able to export to your VM's like this:
# /etc/exports
/Users/brian/share -mapall=501:20 -alldirs
This works well because it shares only to the loopback which gives all your NAT'd VMs access, but no one else. Also it maps all operations to your user ID and group ID so permissions in the share folder stay sane. Your user ID and GID will usually be 501 and 20 on a Mac, but if you want to check, do it like this:
bcook-air:~ brian$ id 
uid=501(brian) gid=20(staff) groups=20(staff),12(everyone),33(_appstore),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),100(_lpoperator),204(_developer),401(
The first two things there are what you are looking for. Don't forget to run nfsd update again after making changes to the exports file.

No comments:

Post a Comment