NFS Command Guide

I’ve been doing a large amount amount of work with NFS clients and severs over the past few days and thought it may be wise to note down some useful commands.

For reference, the NFS Server is Windows Server 2012 R2 and the client is CentOS 7.

To view NFS exports on a server

[root@rsync01 ~]# showmount -e 172.16.4.32
Export list for 172.16.4.32:
/NFS1 172.16.4.36

To manually mount an NFS share

mount -t nfs 172.16.4.31:/NFS1 /data/NFS1/

To manually mount an NFS share using NFS version 4.1

mount -t nfs 172.16.4.31:/NFS1 /data/NFS1/ -o nolock,nfsvers=4.1

To determine which version of NFS the server is offering and over which transport protocol

[root@rsync01 ~]# rpcinfo 172.16.4.32
   program version netid     address                service    owner
    100003    2    tcp       0.0.0.0.8.1            nfs        superuser
    100003    3    tcp       0.0.0.0.8.1            nfs        superuser
    100003    2    udp       0.0.0.0.8.1            nfs        superuser
    100003    3    udp       0.0.0.0.8.1            nfs        superuser
    100003    2    tcp6      ::.8.1                 nfs        superuser
    100003    3    tcp6      ::.8.1                 nfs        superuser
    100003    2    udp6      ::.8.1                 nfs        superuser
    100003    3    udp6      ::.8.1                 nfs        superuser
    100003    4    tcp       0.0.0.0.8.1            nfs        superuser
    100003    4    tcp6      ::.8.1                 nfs        superuser

To view the current mounts and which version of NFS is used

[root@rsync01 ~]# df -hT
Filesystem                           Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos_hc3--rsync01-root xfs        18G  1.8G   16G  10% /
devtmpfs                             devtmpfs  912M     0  912M   0% /dev
tmpfs                                tmpfs     921M     0  921M   0% /dev/shm
tmpfs                                tmpfs     921M   20M  901M   3% /run
tmpfs                                tmpfs     921M     0  921M   0% /sys/fs/cgroup
/dev/sda1                            xfs       497M  184M  313M  37% /boot
172.16.4.31:/NFS1                    nfs4       26T  271G   26T   2% /data/NFS1

To automatically mount an NFS share on boot - edit /etc/fstsab

172.16.4.32:/NFS1 /data/NFS1 nfs defaults 0 0