Solved Mounting NFSv4 on OS X

eydaimon

Active Member

Reaction score: 4
Messages: 116

Code:
$ cat /etc/rc.conf
nfs_server_enable="YES"
nfsv4_server_enable="YES"
nfsuserd_enable="YES"
Code:
$ cat /etc/exports
V4: /
Code:
$ uname -a
Darwin nero.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.1
15.4~1/RELEASE_X86_64 x86_64

$ mount -t nfs -o vers=4 luffy:/ tmp
mount_nfs: can't mount / from luffy onto /Users/daniel/tmp: Permission denied
What am I missing?
 

woodsb02

Active Member

Reaction score: 71
Messages: 165

I'm no expert in NFS mounts, but this section of the man page exports(5) looks like it might explain it:
Code:
In a mount entry, the first field(s) specify the directory path(s) within a server file system that can be mounted on by the corresponding client(s).
There are three forms of this specification.
The third form has the string ``V4:'' followed by a single absolute path name, to specify the NFSv4 tree root.
This line does not export any file system, but simply marks where the root of the server's directory tree is for NFSv4 clients. The exported file systems for NFSv4 are specified via the other lines in the exports file in the same way as for NFSv2 and NFSv3.
 
OP
eydaimon

eydaimon

Active Member

Reaction score: 4
Messages: 116

I've read the documentation more times than I'd like to admit. Do you have a suggestion of what I should change? This has not clarified anything for me.
 

kpa

Beastie's Twin

Reaction score: 1,846
Messages: 6,318

You need to specify both the V4 -line and a plain path (or more paths if needed) so that there is something to export:
Code:
/
V4: /
 

woodsb02

Active Member

Reaction score: 71
Messages: 165

Having reviewed Thread 23526, I think you need to change your /etc/exports file to have the following (adjust network and mask for your requirements):
Code:
V4: /
/ -maproot=root -network 192.168.1.0 -mask 255.255.255.0
Note that NFS mounting the root directory on your OS X means that if you use the OS X root user, you get full root access to the whole server filesystem (seems ominous).

Also, if using a non-root user on OS X, make sure the same UID exists on the server (or instead use the -mapall flag to set which user credential on the server should be used for accessing the server filesystem).
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 3,182
Messages: 11,426

This really belongs on a dedicated OS X forum. Their implementation may not be compatible to FreeBSD's.
 
OP
eydaimon

eydaimon

Active Member

Reaction score: 4
Messages: 116

Allright, so now I have:
Code:
root@luffy /etc# cat /etc/exports
/ -mapall=daniel 192.168.0.3
V4: /
and I'm still getting the same permission denied:
Code:
[~]$ mount -t nfs -o vers=4 luffy:/ tmp
mount_nfs: can't mount / from luffy onto /Users/daniel/tmp: Permission denied
 

kpa

Beastie's Twin

Reaction score: 1,846
Messages: 6,318

I'm pretty sure you need root privileges to mount anything, even on your own home directory or its subdirectories. Try: sudo mount -t nfs -o vers=4 luffy:/ tmp.
 
OP
eydaimon

eydaimon

Active Member

Reaction score: 4
Messages: 116

I got it working. Thanks for everyone's help. Here's what I have:
Code:
root@luffy /etc# cat /etc/exports
V4: /titan
/titan -maproot=root -network 192.168.0.3
and zfs set sharenfs=on was important to get it to share for ZFS.
 
Top