Table of Contents
NFS (Network File System) is a file-sharing protocol that allows Linux systems to access files and directories over a network as if they were stored locally. It is commonly used in server environments, VPS deployments, virtualization platforms, and private networks. Ubuntu 24.04 includes native support for NFS, making it a reliable solution for centralized storage and file sharing.
Step 1: Update the System
Before installing NFS, update your Ubuntu system to ensure all packages are current.This helps prevent package conflicts during installation.
sudo apt update && sudo apt upgrade -y
Step 2: Install the NFS Server Package
To enable file sharing services on Ubuntu 24.04, you must install the NFS server package, which provides the tools and services required to create and manage NFS shares.
sudo apt install nfs-kernel-server -y
Verify that the service is installed and running:
sudo systemctl status nfs-kernel-server
Step 3: Create a Shared Directory
Create a directory that will be accessible to NFS clients.This directory will be exported through NFS
sudo mkdir -p /srv/nfs/shared
Set the required permissions:
sudo chown nobody:nogroup /srv/nfs/shared
sudo chmod 777 /srv/nfs/shared
Step 4: Configure NFS Exports
The /etc/exports file controls which directories are shared and which clients can access them.Open the file.Save the file after making the changes.
sudo nano /etc/exports
Add the following line:
/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check)
Step 5: Apply NFS Export Configuration
After configuring the NFS exports file on Ubuntu 24.04, you must apply the changes so the NFS server can activate and share the configured directories with client systems
sudo exportfs -a
sudo exportfs -v
Restart the service:
sudo systemctl restart nfs-kernel-server
Step 6: Allow NFS Through Firewall
To allow Ubuntu 24.04 NFS clients to connect securely to the NFS server, the firewall must permit NFS traffic through the required network ports.
sudo ufw allow from 192.168.1.0/24 to any port nfs
Reload the firewall:
sudo ufw reload
Step 7: Install the NFS Client
Install the NFS client package on the machine that will access the shared directory.This package enables NFS mounting on Ubuntu systems.
sudo apt install nfs-common -y
Step 8: Mount the NFS Share
Create a mount point on the client machine.Replace 192.168.1.10 with the IP address of your NFS server.
sudo mkdir -p /mnt/nfs-share
df -h
Mount the shared directory:
sudo mount 192.168.1.10:/srv/nfs/shared /mnt/nfs-share
Step 9: Configure Automatic Mounting
To automatically mount the NFS share after a reboot, add it to the /etc/fstab file.If no errors appear, automatic mounting is configured correctly.
sudo nano /etc/fstab
sudo mount -a
Test the configuration:add
192.168.1.10:/srv/nfs/shared /mnt/nfs-share nfs defaults 0 0
Step 10: Test the NFS Share
Verify that the shared directory is working properly between the server and client systems.Create a test file:If the file appears, the NFS share is functioning correctly.
touch /mnt/nfs-share/test-file
Check the server directory:
ls /srv/nfs/sharedNeed a Linux Server for This?
Run Debian, Ubuntu, or any Linux distro on DropVPS — fast NVMe SSD, full root access, and 24/7 support. Perfect for everything you just read.
- Full Root Access
- Debian & Ubuntu Ready
- 99.99% Uptime
- 24/7 Support
No commitment · Cancel anytime
