Ever spent hours digging through online forums because your team’s shared files suddenly disappeared? You’re not alone. Network File System (NFS) storage issues can turn a productive workday into a troubleshooting nightmare.

But it doesn’t have to be that way. With a properly configured NFS server on Ubuntu, you can create a reliable file-sharing system that your entire team can access seamlessly.

This guide walks you through setting up an NFS server and client on Ubuntu with clear, no-nonsense steps. No complicated jargon or unnecessary configurations—just what works.

What makes NFS different from other file-sharing protocols? And why do system administrators consistently choose it for Linux environments? The answers might surprise you.

Understanding NFS and Its Benefits

What is Network File System (NFS)

NFS isn’t complicated – it’s just a protocol that lets your Linux computers share files over a network. Think of it as a virtual USB drive that connects multiple machines. One computer (the server) shares folders, while others (clients) access those folders as if they were local. No more USB shuffling or email attachments!

Advantages of using NFS in Ubuntu environments

NFS shines in Ubuntu setups because it’s lightning fast, already built into your system, and crazy efficient with resources. Your users can access the same files from any computer, keeping everything in sync. Plus, it’s way less complicated than other sharing solutions – no fancy hardware needed, just your existing network.

Common use cases for NFS servers

Home users love NFS for sharing media libraries – imagine all your movies accessible from any device. Developers use it to keep code consistent across testing environments. In offices, it’s perfect for document sharing without the headache of cloud services. And in data centers? It’s the backbone for handling VM storage and high-performance computing tasks.

Prerequisites for NFS Setup

A. System requirements for NFS server and client

Setting up NFS isn’t complicated, but you’ll need a few things first. Both your server and client machines should run Ubuntu (18.04 or newer works great). The server needs enough storage space to share, while clients need network access and mounting privileges. 2GB RAM and single-core processors will handle basic NFS operations fine.

B. Required permissions and network considerations

Network file sharing demands proper security. Your server needs a static IP address to maintain consistent connections. Both machines must have proper firewall configurations allowing NFS traffic (ports 111, 2049, and 20048). User permissions matter too – mismatched UIDs between systems can cause headaches with file ownership.

C. Preparing your Ubuntu systems

First, update both systems with sudo apt update && sudo apt upgrade. Install necessary packages with sudo apt install nfs-kernel-server on the server and sudo apt install nfs-common on clients. Create your shared directory on the server with sudo mkdir /shared and set permissions with sudo chown nobody:nogroup /shared.

D. Checking network connectivity between systems

Before configuring NFS, verify your machines can talk to each other. Use ping [server-ip] from the client to test basic connectivity. If that works, check if required ports are accessible with telnet [server-ip] 2049. No connection? Check your firewall settings with sudo ufw status and open necessary ports.

Installing NFS Server on Ubuntu

A. Updating your package repositories

Before installing the NFS server, update your system. Open a terminal and run:

sudo apt update
sudo apt upgrade -y

This ensures you get the latest version of the NFS server package and its dependencies.

B. Installing the NFS kernel server package

Install the NFS server with:

sudo apt install nfs-kernel-server -y

This package provides the essential functionality needed for hosting shared directories on your Ubuntu system.

C. Verifying the installation

Check if the NFS service is running correctly:

sudo systemctl status nfs-kernel-server

You should see “active (running)” in the output. If not, start it with:

sudo systemctl start nfs-kernel-server

Configuring the NFS Server

A. Creating shared directories with proper permissions

First, create the directory you want to share:

sudo mkdir -p /nfs/shared_data

Now set ownership and permissions that make sense for your use case:

sudo chown nobody:nogroup /nfs/shared_data
sudo chmod 777 /nfs/shared_data

B. Configuring the exports file

Edit the exports file to define which directories to share:

sudo nano /etc/exports

Add this line to share with specific IP addresses:

/nfs/shared_data 192.168.1.0/24(rw,sync,no_subtree_check)

C. Setting up access control rules

Firewall rules matter! Open NFS ports:

sudo ufw allow from 192.168.1.0/24 to any port nfs

For extra security, implement NFS-specific host controls:

sudo nano /etc/hosts.allow

Add: rpcbind mountd nfsd statd lockd rquotad : 192.168.1.0/255.255.255.0

D. Restarting NFS services

Apply your changes by restarting the NFS services:

sudo systemctl restart nfs-kernel-server

Export your shared directories:

sudo exportfs -a

E. Testing server configuration

Verify exports are working:

sudo exportfs -v

Check if NFS services are running properly:

sudo systemctl status nfs-kernel-server

Setting Up NFS Client on Ubuntu

Setting Up NFS Client on Ubuntu

A. Installing necessary client packages

Setting up an NFS client on Ubuntu is much simpler than configuring the server. You’ll need to install just one package:

sudo apt update
sudo apt install nfs-common -y

This package provides all the NFS client functionality you need without the server components.

B. Creating mount points for NFS shares

Now create directories to serve as mount points for your NFS shares:

sudo mkdir -p /mnt/nfs/home
sudo mkdir -p /mnt/nfs/var/nfs

These directories will act as gateways to your NFS server’s shared folders.

C. Testing manual connections to the NFS server

Time to test if everything works properly:

sudo mount -t nfs 192.168.1.100:/home /mnt/nfs/home
sudo mount -t nfs 192.168.1.100:/var/nfs /mnt/nfs/var/nfs

Verify the mounts with df -h. You should see your NFS shares listed with their respective sizes.

Mounting NFS Shares Automatically

Mounting NFS Shares Automatically

A. Configuring the fstab file for permanent mounts

Want your NFS shares to stick around after reboots? Edit your /etc/fstab file and add a line like this:

server:/shared/folder /mount/point nfs defaults 0 0

Save it, run mount -a, and you’re good to go.

B. Setting mount options for optimal performance

Fine-tune your NFS mounts with these options:

server:/shared/folder /mount/point nfs rw,sync,hard,intr 0 0

The sync option ensures data integrity while hard and intr help handle server disconnections gracefully.

C. Implementing automount functionality

Tired of manually mounting shares? Automount to the rescue! Install it with:

sudo apt install autofs

Configure /etc/auto.master and create mapping files to have shares mount only when accessed – saving system resources and preventing boot delays.

Securing Your NFS Server

A. Implementing firewall rules for NFS traffic

Lock down your NFS server with proper firewall rules. Use UFW to restrict access to only trusted IP addresses:

sudo ufw allow from 192.168.1.0/24 to any port 2049

This limits NFS connections to devices on your local network only. Don’t leave your file server exposed to the entire internet!

B. Using NFSv4 security features

NFSv4 packs serious security upgrades over older versions. Enable ID mapping for consistent user permissions:

# In /etc/idmapd.conf
Domain = yourdomain.local

This ensures files maintain correct ownership when accessed by different clients across your network.

C. Setting up Kerberos authentication (optional)

Want bank-level security for your files? Kerberos is your answer. Install the packages:

sudo apt install krb5-user libpam-krb5

Then configure your Kerberos realm in /etc/krb5.conf and integrate it with your NFS exports. No more password-free access to your precious data!

D. Best practices for NFS security

NFS security isn’t just about configuration—it’s a mindset. Always use the principle of least privilege: export only what’s necessary, to who’s necessary. Monitor logs regularly with:

sudo tail -f /var/log/syslog | grep nfs

And encrypt your network traffic when possible. Your future self will thank you when you don’t get hacked.

Troubleshooting Common NFS Issues

Troubleshooting Common NFS Issues

A. Resolving permission problems

NFS permission issues usually boil down to user ID mismatches. Check your /etc/exports file for proper options like no_root_squash or all_squash. If files show as “nobody:nogroup,” sync the UIDs between your systems. Sometimes a simple chmod and chown on the exported directory fixes stubborn permission problems.

B. Fixing connection refused errors

Connection refused? First, make sure the NFS server is actually running: systemctl status nfs-server. Check your firewall settings and open ports 111, 2049, and 20048. Verify the client is listed in /etc/exports and run exportfs -ra to refresh your exports. Sometimes it’s just a network hiccup – try restarting the NFS service.

C. Addressing performance bottlenecks

NFS slowdowns kill productivity. Tweak your mount options – try rsize=1048576,wsize=1048576 for larger read/write blocks. Use async instead of sync when data integrity isn’t critical. Network congestion? Consider upgrading to a gigabit connection or using jumbo frames if your hardware supports it. Monitor with nfsstat to identify bottlenecks.

D. Using NFS debugging tools

When things get weird, reach for these tools: rpcinfo shows if RPC services are responding, showmount -e server_ip confirms exports, and nfsstat provides detailed statistics. For deeper issues, increase verbosity with mount -v or check system logs with journalctl -u nfs-server. The ultimate troubleshooter? Wireshark to capture and analyze NFS packet traffic.

Setting up your own NFS server and client on Ubuntu enables seamless file sharing across your network with remarkable efficiency. By following the step-by-step instructions outlined in this guide, you can configure a robust file-sharing system that maintains consistent permissions, offers excellent performance, and integrates naturally with Linux environments.

Remember to prioritize security when implementing your NFS setup by properly configuring firewalls, using strong access controls, and keeping your systems updated. Whether you’re managing a small home network or an enterprise environment, NFS provides a reliable solution for centralized file storage and sharing. Start implementing your NFS system today to experience streamlined file management across all your Ubuntu machines.