1. What is NFS? Benefits and Basic Use Cases on Ubuntu
NFS (Network File System) is a protocol for sharing files over a network. This article provides a complete guide on using NFS on Ubuntu, highlighting its benefits for server management and explaining how to set it up.
How NFS Works and Its Use Cases
NFS simplifies file sharing between servers and clients, functioning as a remote file system. It is particularly useful for synchronizing files across multiple Linux servers and for backup purposes in cloud environments.
Benefits of Using NFS on Ubuntu
- Efficient Data Synchronization: Multiple servers can access the same data, making management easier.
- High Compatibility Between Linux Systems: NFS is supported by many Linux distributions, including Ubuntu.
- Usability in Cloud Services: NFS allows flexible data sharing, even in cloud storage environments.
2. Prerequisites: System Requirements and NFS Installation
To run NFS effectively, a suitable system environment is required. Below are the system requirements and installation steps for NFS.
Hardware and Software Requirements
- CPU and Memory: A dual-core CPU or higher and at least 2GB of RAM are recommended.
- Network and Storage: A stable Ethernet connection and dedicated storage for shared data.
Installing the NFS Package
Install the NFS server and client packages using the following commands:
sudo apt update
sudo apt install nfs-kernel-server nfs-common
Using an LTS version of Ubuntu ensures long-term support and a stable environment.

3. Setting Up the NFS Server
This section explains how to set up an NFS server on Ubuntu and configure a shared directory.
Creating and Configuring the Shared Directory
- Creating the Directory and Setting Permissions: Run the following commands to create a shared directory at
/nfs
and grant access to all clients.
sudo mkdir /nfs
sudo chmod 777 /nfs
- Editing the /etc/exports File: Add the following entry to configure access settings.
/nfs *(rw,sync,no_subtree_check)
This configuration allows read and write access from all clients.
Firewall Configuration
If the firewall is enabled, open port 2049 for NFS traffic.
sudo ufw allow from <client IP address> to any port nfs
4. Configuring the NFS Client
Setting up the NFS client involves installing the necessary packages and configuring the mount settings for connecting to the NFS server.
Installing Packages and Mounting the NFS Directory
- Installing the NFS Client Package: Install
nfs-common
on the client system.
sudo apt install nfs-common
- Mounting the NFS Directory: Use the following command to manually mount the directory or add an entry to
/etc/fstab
for automatic mounting.
sudo mount <server IP address>:/nfs /mnt
Automatic mounting configuration:
<server IP address>:/nfs /mnt nfs defaults 0 0
To check the mount status, run the df -h
command.

5. Operation Management and Troubleshooting
This section covers common issues encountered when operating NFS and useful commands for management.
Automatic Mount Configuration
To ensure that the NFS directory remains mounted after a reboot, enable the netfs service to start automatically using the chkconfig
command.
sudo chkconfig netfs on
Common Issues and Solutions
- Access Denied Errors: If you encounter a “Permission denied” error, check the directory permissions and the
/etc/exports
file settings. - NFS Version Mismatch: To avoid compatibility issues due to different NFS versions, specify the version using options like
nfsvers=3
in the mount command.
6. Advanced Use Cases for NFS
Load Balancing for Web Servers
NFS is useful in environments where multiple web servers need access to the same files. By using NFS, data can be shared efficiently between servers, helping to balance the load.
Using NFS in Cloud Environments
Cloud services like AWS and GCP offer NFS-based file-sharing solutions, enabling efficient data management in cloud environments.
7. Conclusion
This article has provided a comprehensive guide on setting up NFS on Ubuntu, including installation, management, and troubleshooting techniques. By implementing NFS, you can streamline file sharing, improve system flexibility, and optimize performance in cloud environments or high-load web server setups.