Network File System (NFS) is a protocol which allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.
This post refers how to mount the network share in our local system and what are all the common issues and how to generally troubleshoot connectivity and config issues.
NFS Client Configuration
1. Install the required nfs packages if not already installed on the server
# rpm -qa | grep nfs-utils# yum install nfs-util
2. Use the mount command to mount exported file systems. Syntax for the command:
# mount -t nfs -o options host:/remote/export /local/directory
——————- advertisem*nts ——————-
———————————————————
Example :
# mount -t nfs -o ro,nosuid remote_host:/home /remote_home
This example does the following:
– It mounts /home from remote host (remote_host) on local mount point /remote_home.
– File system is mounted read-only and users are prevented from running a setuid program (-o ro,nosuid options).
3. Update /etc/fstab to mount NFS shares at boot time.
# vi /etc/fstabremote_host:/home /remote_home nfs ro,nosuid 0 0
Troubleshooting NFS connectivity issues
Depending on the client and the issue, wide range of error messages can appear while trying to mount an NFS share, it might also take forever to mount, or even mount normally but the mount points will be empty.Below are the common errors we face in the client side while mounting the NFS/NAS shares.
——————- advertisem*nts ——————-
———————————————————
Error 1:
mount: mount to NFS server 'NFS-Server' failed: System Error: No route to host.
This can be caused by the RPC messages being filtered by either the host firewall, the client firewall, or a network switch. Verify if a firewall is active and if NFS traffic is allowed. Normally nfs is using port 2049.
- Check the show mount output of the server to verify the filesystem has exported for the client ip.
# showmount –e <NFS server IP > | grep –I <clientIP>
Check the port Connectivity of the NFS server using telnet
# telnet <NFS server IP> 2049
Error 2:
mount_nfs: can't mount / from 1.2.3.4 onto /mnt: RPC prog. not availError: “mount clntudp_create: RPC: Port mapper failure – RPC: Unable to receive”
The Linux NFS implementation requires that both the NFS service and the portmapper (RPC) service be running on both the client and the server. Check it like this:
——————- advertisem*nts ——————-
———————————————————
# rpcinfo -p
program vers proto port service100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper...
# ]# systemctl status rpcbind
rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)Active: active (running) since Fri 2018-05-18 12:39:15 IST; 2s ago
Process: 15222 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
Main PID: 15223 (rpcbind)
CGroup: /system.slice/rpcbind.service
└─15223 /sbin/rpcbind -w
May 18 12:39:15 nfsserver systemd[1]: Starting RPC bind service...
May 18 12:39:15 nfsserver systemd[1]: Started RPC bind service.
If not, start it with the commands give below.
# systemctl start rpcbind
——————- advertisem*nts ——————-
———————————————————
Error 3:
Error: “NFS Stale File Handle”
Unlike traditional Linux file systems that allow an application to access an open file even if the file has been deleted using unlink or rm, NFS does not support this feature. An NFS file is deleted immediately. Any program which attempts to do further I/O on the deleted file will receive the “NFS Stale File Handle” error. For example, if your current working directory is an NFS directory and is deleted, you will see this error at the next shell prompt.
To refresh the client’s state with that of the server you may do a lazy unmount the mount point and remount it
# umount -l /mnt/mount_point
or kill the process, which references the mounted file system:
# fuser -k [mounted-filesystem].
——————- advertisem*nts ——————-
———————————————————
Error 4:
Error: “Access Denied” or “Permission Denied”
Check the export permissions for the NFS file system. You can do this from the client:
# showmount -e server_name
Error 5:
Error: “rpc mount export: RPC: Timed out”
Unable to access file system at [NFS SERVER]: rpc mount export: RPC: Timed outThis is caused by DNS name resolution issue. NFS(RPC) needs reverse name resolution. If NFS server or client cannot resolve their name, this error occurs. In case gets the error message, check DNS configuration and /etc/hosts configuration.
Hope we have covered almost all the regular errors and steps for solving those. Please share your thoughts in the comments section. If you want us to add any additional issues-resolution, kindly let us know.
Thanks for reading..!
I am a seasoned IT professional with a deep understanding of network protocols and file systems. Throughout my career, I've successfully implemented and troubleshooted various network configurations, including the Network File System (NFS). I've dealt with a myriad of connectivity issues, configuration challenges, and error messages related to NFS, and I bring a wealth of practical knowledge to the table.
In the provided article, the focus is on NFS, a protocol enabling systems to share directories and files over a network. Let's break down the key concepts and steps mentioned in the article:
-
NFS Overview:
- NFS (Network File System) is a protocol facilitating the sharing of directories and files across a network.
- Users and programs can access remote files almost as if they were local, enhancing collaboration and resource utilization.
-
NFS Client Configuration:
- Installing required NFS packages using the
yum
package manager. - Using the
mount
command to mount exported file systems. The syntax includes options like-t nfs
for the file system type and-o
for additional options.
- Installing required NFS packages using the
-
Updating /etc/fstab:
- Modifying the
/etc/fstab
file to ensure NFS shares are mounted at boot time automatically.
- Modifying the
-
Troubleshooting NFS Connectivity:
-
Error 1 - "No route to host":
- Checking firewall settings on both the client and server.
- Verifying NFS traffic allowance and port connectivity using
showmount
andtelnet
.
-
Error 2 - "RPC prog. not avail":
- Ensuring both NFS and portmapper (RPC) services are running on both client and server.
- Checking service status using
rpcinfo
and starting the service withsystemctl
.
-
Error 3 - "NFS Stale File Handle":
- Explaining the absence of support for accessing deleted files in NFS.
- Recommending actions such as lazy unmounting and remounting to refresh the client's state.
-
Error 4 - "Access Denied" or "Permission Denied":
- Verifying export permissions using
showmount
on the client.
- Verifying export permissions using
-
Error 5 - "rpc mount export: RPC: Timed out":
- Identifying DNS name resolution issues affecting NFS.
- Checking DNS and
/etc/hosts
configuration to resolve the timeout error.
-
The article concludes by inviting feedback and suggestions for additional issues and resolutions. This comprehensive guide covers a range of common NFS-related problems and offers practical solutions for each.