NFS (Network File System) allows Linux systems to share directories over a network. It is the standard protocol for shared storage in Linux environments, used for home directories, media servers, and cluster storage. This guide sets up an NFS server and client on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS on both server and client
- Both machines on the same network
- A user with sudo privileges on both
Step 1 – Install NFS Server
sudo apt update
sudo apt install nfs-kernel-server -y
sudo systemctl start nfs-kernel-server
sudo systemctl enable nfs-kernel-server
Step 2 – Create a Share Directory
sudo mkdir -p /srv/nfs/shared
sudo chown nobody:nogroup /srv/nfs/shared
sudo chmod 755 /srv/nfs/shared
Step 3 – Configure Exports
sudo nano /etc/exports
Add:
/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)
Step 4 – Apply Export Changes
sudo exportfs -a
sudo exportfs -v
sudo systemctl restart nfs-kernel-server
Step 5 – Configure UFW
sudo ufw allow from 192.168.1.0/24 to any port nfs
Step 6 – Install NFS Client and Mount
On the client machine:
sudo apt install nfs-common -y
sudo mkdir -p /mnt/nfs/shared
sudo mount 192.168.1.100:/srv/nfs/shared /mnt/nfs/shared
df -h | grep nfs
Step 7 – Permanent Mount via fstab
On the client:
echo '192.168.1.100:/srv/nfs/shared /mnt/nfs/shared nfs defaults,_netdev 0 0' | sudo tee -a /etc/fstab
sudo mount -a
Conclusion
NFS file sharing is configured on Ubuntu 26.04 LTS. Your server exports directories that clients can mount and use as if they were local filesystems. Use NFS version 4 for improved security and performance over NFSv3.