NFS Server Setup on Ubuntu 20.04: Complete Configuration Guide

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.

Why Choose NFS for File Sharing?

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:

  • Centralized file management
  • Easy access to shared resources
  • Seamless integration with Linux systems
  • Reduced data duplication
  • Efficient network-based storage

NFS Server Setup: Install Required Packages

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.

Create and Prepare Shared Directories

Before exporting files, create directories that will be shared with client systems.

Example shared locations may include:

  • Web content directories
  • Backup repositories
  • Project storage folders
  • Media libraries

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.

NFS Server Setup: Configure Exports

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 access
  • ro – Read-only access
  • sync – Write changes immediately to disk
  • no_subtree_check – Improves performance
  • root_squash – Restricts root privileges from clients

After saving the configuration, apply the changes:

sudo exportfs -ar

You can verify active exports using:

sudo exportfs -v

Configure Firewall Access

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.

Connect Linux Clients to the NFS Share

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.

Testing and Managing Access

Once the share is mounted, test read and write permissions according to the export policies you’ve configured.

Verify that:

  • Authorized users can create files where permitted.
  • Read-only shares prevent modifications.
  • Client access follows assigned permissions.

If a share is no longer needed, unmount it with:

sudo umount /mnt/share

Conclusion

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

Cyber Defence

Recent Posts

Install Gitea Ubuntu: Complete Setup Guide for Developers

Managing source code efficiently is essential for modern software development, and Install Gitea Ubuntu is…

1 day ago

Install Ruby Ubuntu – 3 Easy Ways to Set Up Ruby on Ubuntu 20.04

Ruby remains one of the most popular programming languages for web development, automation, and software…

1 day ago

Plex Media Server Setup: Install and Configure on Ubuntu 20.04

A Plex Media Server Setup on Ubuntu 20.04 is one of the easiest ways to…

1 day ago

Why Deploying AI Is Just the Beginning: The Case for Ongoing AI Operations Monitoring

Most enterprise AI programs treat deployment as the destination. The business case is built around…

2 days ago

Bash Scripting Best Practices Every Beginner Should Know

Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…

1 week ago

How To Create A Self-Signed SSL Certificate Using Bash And OpenSSL

Introduction A self-signed SSL certificate is a certificate that is created and signed by the…

1 week ago