Server Configuration
- In /etc/rc.conf, add the following lines
nfs_server_enable="YES" nfsv4_server_enable="YES" nfsuserd_enable="YES"
- Start the NFS daemons by running
/etc/rc.d/nfsd start
- Open /etc/exports in your preferred editor. Add a "V4:" line to the file, specifying the root of your NFSv4 tree. There are two choices at this point. Option 1 is to place your NFSv4 root at a location other than the root of the server filesystem. With this option, you can create an arbitrary NFS tree for clients to attach to, independent of how data is actually situated on the filesystem(s). Nullfs mounts may be used to include outside directories in the NFS root. Option 2 is to make the NFSv4 root the actual root of the system. This preserves the behavior of old NFS implementations. Regardless of where you put your V4 root, you must also add export lines, in the same style as NFSv3. The exports man page can be helpful here, and discusses the security implications of using NFSv4.
# Option 1 V4: /nfsv4 -network=10.0.0.0 -mask=255.255.255.192 /nfsv4/ports -maproot=root: -network=10.0.0.0 -mask=255.255.255.192 # Option 2 V4: / -network=10.0.0.0 -mask=255.255.255.192 /usr/pxe/ports -maproot=root: -network=10.0.0.0 -mask=255.255.255.192
- Reload the exports file by signalling mountd
killall -HUP mountd
Client Configuration
Clients should now be able to mount the exported filesystem using the following commands, corresponding to the NFSv4 root options specified above. Notice that with option 1, the remote path omits the /nfsv4 prefix of the server.# Option 1 mount -t nfs -o nfsv4 server:/ports /mnt # Option 2 mount -t nfs -o nfsv4 server:/usr/pxe/ports /mnt
Errors
If you get the following error when trying to mount from the client, don't be fooled:mount_nfs: /mnt, : No such file or directory
This may indicate that you have misspelled the remote path in your mount command. It may also indicate that you have an error in your exports file, or that your exports file is not configured the way you think it is. Go back and read step 3 of the Server Configuration.