Network file sharing remains an essential part of Linux infrastructure, and NFS Server Setup is one of the most reliable methods for providing centralized storage across multiple systems. Using the Network File System (NFS), administrators can share directories over a network, allowing remote machines to access files as if they were stored locally.
In this guide, you’ll learn how to configure an NFS server on Ubuntu 20.04, export shared directories, connect client systems, and implement basic security practices.
NFS is a widely used distributed file system protocol that simplifies data sharing between Linux and Unix-based systems. It is particularly useful in development environments, backup infrastructures, and enterprise networks where multiple machines need access to the same files.
Some key advantages include:
The first step in any NFS Server Setup process is installing the necessary server software.
Update the package repository and install the NFS server package:
sudo apt updatesudo apt install nfs-kernel-server
Once installed, Ubuntu automatically starts the NFS services. You can verify active NFS versions by checking the system configuration.
Modern Ubuntu installations support NFSv3 and NFSv4 by default, making them suitable for most production environments.
Before exporting files, create directories that will be shared with client systems.
Example shared locations may include:
To simplify management, many administrators create a dedicated NFS root directory and use bind mounts to map existing folders into the NFS structure.
This approach helps organize exports while maintaining existing directory layouts.
The core of an NFS deployment lies in defining exports. Export rules determine which systems can access shared resources and what permissions they receive.
Edit the exports configuration file:
sudo nano /etc/exports
Typical export options include:
rw – Read and write accessro – Read-only accesssync – Write changes immediately to diskno_subtree_check – Improves performanceroot_squash – Restricts root privileges from clientsAfter saving the configuration, apply the changes:
sudo exportfs -ar
You can verify active exports using:
sudo exportfs -v
If your server uses UFW, allow NFS traffic only from trusted networks.
Example:
sudo ufw allow from 192.168.1.0/24 to any port nfs
Restricting access by subnet improves security and reduces exposure to unauthorized systems.
Client systems require NFS utilities before they can mount remote shares.
On Ubuntu or Debian systems, install:
sudo apt install nfs-common
Create a mount point and connect to the remote share:
sudo mount -t nfs SERVER_IP:/shared-folder /mnt/share
After mounting, users can access files directly through the local mount point.
For persistent mounts across reboots, add the configuration to /etc/fstab.
Once the share is mounted, test read and write permissions according to the export policies you’ve configured.
Verify that:
If a share is no longer needed, unmount it with:
sudo umount /mnt/share
A properly configured NFS Server Setup provides a fast and efficient way to share files across Linux systems. By installing the NFS server, creating exports, securing network access, and configuring client mounts, administrators can build a reliable centralized storage solution. For environments handling sensitive information, consider adding Kerberos authentication or encrypted alternatives to further strengthen your NFS Server Setup
Managing source code efficiently is essential for modern software development, and Install Gitea Ubuntu is…
Ruby remains one of the most popular programming languages for web development, automation, and software…
A Plex Media Server Setup on Ubuntu 20.04 is one of the easiest ways to…
Most enterprise AI programs treat deployment as the destination. The business case is built around…
Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…
Introduction A self-signed SSL certificate is a certificate that is created and signed by the…