In this article I will share multiple commands and method to cover below topics:
- Show NFS Shares configured on the NFS Server
- List NFS mount points on the NFS Clients
- List NFS Clients which are connected to the NFS Server
Use showmount to show NFS shares
We can use showmount
command to show NFS shares on the NFS Server using NFSv3 protocol.
showmount
can be used to show NFS shares only if you are using rpcbind
. With NFSv4, rpcbind
is not used any more so showmount
will throw clnt_create: RPC: Program not registered
error on NFSv4 server configuration.# showmount --exports
Export list for server1.example.com:
/nfs_shares *
/priv_shares 192.168.0.0/255.255.255.0
/pub_shares 10.10.10.0/255.255.255.0
You can also give server details to show NFS shares for the respective server
# showmount --exports 10.10.10.2
Export list for 10.10.10.2:
/nfs_shares *
/priv_shares 192.168.0.0/255.255.255.0
Use exportfs to show NFS shares
You can use exportfs
to show NFS shares with all NFS versions. exportfs -v
will show the currently shared directory lists with all the permissions per directory
# exportfs -v
/pub_shares 10.10.10.0/255.255.255.0(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/priv_shares 192.168.0.0/255.255.255.0(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)
/nfs_shares (sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
Use master export file /var/lib/nfs/etab to show NFS shares
We use /etc/exports
or /etc/exports.d
to add any NFS share. Next when we refresh the list of shares using exportfs -r
or exportfs -a
, the shares list from /etc/exports
and /etc/exports.d
is updated in the master exports table /var/lib/nfs/etab
.
WARNING: You should not edit /var/lib/nfs/etab
file manually. You must always update shares under /etc/exports
and /etc/exports.d
Check the content of /var/lib/nfs/etab
to show NFS shares list and all the applied permission details
# cat /var/lib/nfs/etab
/priv_shares 192.168.0.0/255.255.255.0(ro,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,ro,secure,root_squash,no_all_squash)
/pub_shares 10.10.10.0/255.255.255.0(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,rw,secure,root_squash,no_all_squash)
/nfs_shares *(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,rw,secure,no_root_squash,no_all_squash)
List NFS mount points on NFS Clients
There are various commands and methods to list NFS mount points
Use mount to list NFS mount points
We can use mount
command to list NFS mount points on nfs-client
.
# mount | grep nfs 10.10.10.12:/nfs_shares on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.10.10.16,local_lock=none,addr=10.10.10.12)
Use nfsstat to list NFS mount points
Normally we use nfsstat
to get the NFS mount point usage and statistics. But we can also use nfsstat
to list currently used NFS mount points on nfs-client
.
# nfsstat --mounts
/mnt from 10.10.10.12:/nfs_shares
Flags: rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.10.10.16,local_lock=none,addr=10.10.10.12
Use /proc/mounts to list NFS mount points
We can also check the content of /proc/mounts
to list NFS mount points on nfs-client
# cat /proc/mounts | grep nfs 10.10.10.12:/nfs_shares /mnt nfs4 rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.10.10.16,local_lock=none,addr=10.10.10.12 0 0
List NFS clients connected to NFS Server
Use netstat to list NFS clients connected to NFS server
netstat
is used to list the listening TCP and UDP ports. In the example I have one NFS client connected to the NFS server on 1018 port
# netstat | grep :nfs tcp 0 0 server1.example.com:nfs 10.10.10.16:1018 ESTABLISHED
Use ss to list NFS clients connected to NFS Server
ss
id another utility to investigate sockets and is considered to be a replacement for netstat
in future Linux releases. So we can also use ss
command to list NFS clients connected to the NFS Server. Execute below command on the NFS server to list NFS clients.
# ss -a|grep :nfs udp UNCONN 0 0 *:nfs *:* udp UNCONN 0 0 [::]:nfs [::]:* tcp LISTEN 0 64 *:nfs *:* tcp ESTAB 0 0 10.10.10.2:nfs 10.10.10.16:1018 tcp LISTEN 0 64 [::]:nfs [::]:*
In this example we have one NFS Client currently connected to the NFS server on port 1018.
Lastly I hope the steps from the article to show nfs shares on nfs server, list nfs mount points on nfs clients and list nfs clients connected to nfs server on Linux was helpful. So, let me know your suggestions and feedback using the comment section.
References:
List all the NFS shares using showmount
Related Searches: check nfs mount, list nfs shares, showmount command in linux, nfs client list remote exports, list nfs mount points