Linux nfs share all

Show NFS shares | List NFS mount points | List NFS clients Linux

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

Show NFS shares on 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

Читайте также:  How to install linux fedora

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.

Читайте также:  Сертифицированное программное обеспечение linux

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.

Related Searches: check nfs mount, list nfs shares, showmount command in linux, nfs client list remote exports, list nfs mount points

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

How To Mount And Use NFS Shares On Linux Sharing Files Easily Using NSF

Developed by Sun Microsystems in 1984, NFS or Network File Shares is a file system protocol used for accessing files over a network similar to a local storage device.

NFS Shares are powerful and popular as they allow users to share files and directories over a local network and the internet. However, it is better to limit NFS shares to local and trusted networks as files don’t get encrypted on the machines. However, the problem was addressed and fixed on a recent version of the NFS protocol. You may need to set up complex authentication methods such as Kerberos.

This tutorial will walk you through how to set up NFS shares on a Linux system. Let us get started.

Setting up NFS Server

Let us start by setting up the NFS server. This process is fairly simple, with only a few commands:

Читайте также:  Linux как узнать видеодрайвер

sudo apt-get install nfs-kernel-server

Next, create a directory in the local system which will be used as the NFS’ share root directory:

Set the appropriate permissions to the directory:

Next, edit the exports file in /etc/exports and add the following entry

Setting Up An NFS Client

For you to mount NFS Shares on Linux, you will need to install nfs client tools using the command:

Mounting an NFS Filesystem

The process of mounting NFS file shares is very similar to mounting a regular file system in Linux. You can use the command mount. The general syntax is as:

To accomplish this, start by creating a directory to use as the NFS Share’s mount point.

Next, mount the NFS share using the mount command as shown below:

Once completed, you should have access to the remote shares on the server.

Unmounting File shares

Since an NFS share is similar to a file system, you can unmount it with umount command as:

You can use other options with umount command, such as a force to force-unmount the NFS shares.

Conclusion

The above is a simple guide on how to use and mount NFS shares on a Linux system. There is more to NFS than what we have discussed here; feel free to utilize external resources to learn more.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list

Источник

Оцените статью
Adblock
detector