Mounting NFS Filesystems #
NFS filesystems should be mounted via mount(8), or more specifically, mount_nfs(8).
To mount the /docs filesystem on host 10.0.0.1 to local filesystem /mnt, run:
# mount -t nfs 10.0.0.1:/docs /mnt
To have that filesystem mounted at boot, append a line to your fstab(5):
# echo '10.0.0.1:/docs /mnt nfs ro,nodev,nosuid 0 0' >> /etc/fstab
It is important that you use 0 0 at the end of this line so that your computer does not try to fsck(8) the NFS filesystem on boot.
When accessing an NFS mount as the root user, the server automatically maps root’s access to username nobody and group nobody. This is important to know when considering file permissions. For example, take a file with these permissions:
-rw------- 1 root wheel 0 Dec 31 03:00 _httpd.log
If this file was on an NFS share and the root user tried to access this file from the NFS client, access would be denied.
The user and group that root are mapped to are configurable via the exports(5) file on the NFS server.
Checking Stats on NFS #
One thing to check to ensure NFS is operating properly is that all the daemons have properly registered with RPC. To do this, use rpcinfo(8).
$ rpcinfo -p 10.0.0.1
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 633 mountd
100005 3 udp 633 mountd
100005 1 tcp 916 mountd
100005 3 tcp 916 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
There are a few utilities that allow you to see what is happening with NFS. showmount(8) allows you to view what is currently mounted by whom. There is also nfsstat(1), which shows much more verbose statistics.