
How to Mount NFS Shares on Linux
How to Mount NFS Shares on Linux
Network File System (NFS) is a robust protocol used to share files over a network. It allows a user on a client computer to access files over a network much like local storage is accessed. Here’s a comprehensive guide on how to mount NFS shares on a Linux system.
Prerequisites
- A Linux-based client with root or sudo access.
- An NFS server set up and ready for connection. If not, check out our tutorial on How to Install NFS Server on Linux.
- Network connectivity between the client and the server.
Installing NFS Utilities
First, ensure that the NFS utilities are installed on your client system. Run the following command to install these utilities.
sudo apt update
sudo apt install nfs-common
Mounting the NFS Share
Identify the server’s IP address or hostname and the shared directory’s path. Then, choose a directory on your client machine to use as the mount point, or create a new one:
sudo mkdir -p /mnt/nfs_share
Mount the NFS share using the mount command:
sudo mount server_ip:/server_shared_directory /mnt/nfs_share
Replace server_ip with your NFS server’s IP address and server_shared_directory with the shared path.
Verifying the Mount
After mounting, verify that the NFS share is accessible by listing the contents:
ls -l /mnt/nfs_share
Automatically Mounting NFS Shares
You can configure your system to auto-mount NFS shares by editing the /etc/fstab
file.
server_ip:/server_shared_directory /mnt/nfs_share nfs defaults 0 0
Ensure the entries are correct. To apply changes, either reboot or run:
sudo mount -a
Troubleshooting Common Issues
If you encounter connectivity issues, verify that:
- The NFS service is running on the server.
- No firewall rules block the NFS traffic.
- NFS shares have the right permissions and export settings.
For more detailed troubleshooting, checking the system and NFS logs often provides insight.
Summary Checklist
- Install NFS utilities.
- Create a mount point.
- Mount the NFS share.
- Verify the mounted share.
- Automate mounts using
/etc/fstab
. - Troubleshoot any issues.
With these steps, you can mount and integrate NFS shares into your Linux system seamlessly, ensuring efficient network file handling.