MacOS – How to share directory over NFS from Mac? (w/o macOS Server app)

file-sharingmacosnfsserver.appunix

First of all, I'm happy to pay the $19.99 for the Mac OS Server app from the app store, so that's no problem, it's just that at the moment I only have one specific need – NFS sharing between my macOS sierra host and a virtualbox VM guest running Debian Sarge (don't ask).

This is something I am used to doing in Linux without any difficulty, but the syntax for /etc/exports doesn't seem to be the same? In the man page for exports on macOS it uses explicit flags?

My regular line in /etc/exports on Linux:

# NFS Share to Virtualbox guests:
/path/to/my/shared/directory 192.168.56.0/24(rw,fsid=root,all_squash,anonuid=1000,anongid=1000,no_subtree_check)

Calling nfsd checkexports returns the following:

getaddrinfo() failed for 192.168.56.0/24(rw,fsid=root,all_squash,anonuid=1000,anongid=1000,no_subtree_check)
exports:2: couldn't get address for host: 192.168.56.0/24(rw,fsid=root,all_squash,anonuid=1000,anongid=1000,no_subtree_check)
exports:2: no valid hosts found for export

And if I simplify and change the etc/exports entry to /path/to/my/shared/directory -network 192.168.56.0 -mask 255.255.255.0 I get the following output from nfsd checkexports:

exports:2: path contains non-directory or non-existent components: /path/to/my/shared/directory
exports:2: no usable directories in export entry and no fallback

Note: /path/to/my/shared/directory is obviously a just a placeholder filepath for this question, not my actual entry in /etc/exports ?

Is it just because the line in /etc/exports is crap, or I need some other configuration? or do I need the macOS Server app?

From looking at https://help.apple.com/serverapp/mac/5.3/#/apd106E5632-C4E6-4572-8289-B9ACC652E88C it seems like it might not be anything I need the macOS Server app for?

EDIT:

What I want is the equivalent behaviour and rw permissions of rw,fsid=root,all_squash,anonuid=1000,anongid=1000,no_subtree_check in my exporting, I've got it working with NFS Manager where I can mount the folder on my VM guest but read-only.

Best Answer

What was required was the following line in /etc/exports:

/path/to/shared/dir -mapall=<uid of local user on host machine with correct perms> -network 192.168.56.0 -mask 255.255.255.0

exports(5) is the FreeBSD version, obviously. Once I did some googling for the solution with respect to "FreeBSD" instead of "Mac", the necessary information presented itself, the a colleague pointed out the exact flag needed.

Source: http://www.freebsdmadeeasy.com/tutorials/freebsd/using-freebsd-nfs.php

NFS Manager was helpful in validating the solution but not necessary.