Ubuntu NFS Mount Tutorial: A Complete Step-by-Step Setup Guide

watch 3m, 24s
views 2

10:34, 20.08.2026

Article Content
arrow

  • What Is NFS and Why Use It on Ubuntu?
  • Understanding the Client-Server Model in NFS
  • How to Set Up an NFS Server on Ubuntu (Installation & Configuration)
  • Step 1: Install the NFS Server on Ubuntu
  • Client-Side Setup
  • Step 2: Create and Configure Shared Directories on the Host
  • Step 3: Grant Access to Client Machines
  • Step 4: Export the Shared Directory via NFS
  • Step 5: Open Firewall Access for NFS Traffic
  • Troubleshooting Common NFS Mount Issues
  • 1. Unable to Access Files on a Mounted NFS Share
  • 2. Mounting the NFS Share Fails
  • Error: Permission Denied from Server
  • 3. NFS Performance Bottlenecks and How to Fix Them
  • Best Practices for a Reliable NFS Setup
  • FAQ
  • How do I check if NFS is installed on Ubuntu?
  • Can I mount an NFS share on a Windows machine?
  • Why is my NFS mount read-only on Ubuntu?
  • How do I restart the NFS service on Ubuntu?
  • How do I force an NFS unmount?
  • Does NFS support encryption?
  • How can I view active NFS connections?

What Is NFS and Why Use It on Ubuntu?

The Network File System (NFS) is a protocol that allows you to share directories and files between Linux systems over a network. NFS is particularly useful when you need centralized file storage accessible from multiple machines, common in enterprise environments, development clusters, or home labs. With native support in Ubuntu, NFS offers a lightweight, fast, and easy-to-configure way to manage network file sharing.

Understanding the Client-Server Model in NFS

NFS works on a client-server architecture. The server exports (shares) directories, and the client mounts these directories locally, interacting with them as if they were part of the local file system. This design makes NFS ideal for distributed computing environments, such as compute clusters or Docker-based CI/CD pipelines.

How to Set Up an NFS Server on Ubuntu (Installation & Configuration)

Step 1: Install the NFS Server on Ubuntu

To begin, install the NFS kernel server package:

sudo apt update sudo apt install nfs-kernel-server

This will install the necessary daemons to share directories via NFS.

Client-Side Setup

On the client machine(s), install the NFS client utilities:

sudo apt update sudo apt install nfs-common

Step 2: Create and Configure Shared Directories on the Host

Let’s say you want to share /mnt/shared. First, create the directory and set proper ownership:

sudo mkdir -p /mnt/shared sudo chown nobody:nogroup /mnt/shared

You can adjust permissions based on your use case, e.g., for multi-user write access.

Step 3: Grant Access to Client Machines

Edit the /etc/exports file to define which clients can access which directories:

/mnt/shared 192.168.1.0/24(rw,sync,no_subtree_check)

This allows the entire 192.168.1.x subnet to mount the directory with read/write permissions.

Step 4: Export the Shared Directory via NFS

After editing /etc/exports, reload the export table:

sudo exportfs -a

Ensure the NFS service is enabled and running:

sudo systemctl enable nfs-server sudo systemctl start nfs-server

Step 5: Open Firewall Access for NFS Traffic

Use UFW or iptables to allow NFS-related ports (2049 for NFSv4):

sudo ufw allow from 192.168.1.0/24 to any port nfs sudo ufw reload

Troubleshooting Common NFS Mount Issues

1. Unable to Access Files on a Mounted NFS Share

Make sure the NFS share directory has proper permissions. If it’s owned by nobody:nogroup, adjust as needed using chown or ACLs for finer control.

2. Mounting the NFS Share Fails

Ensure the server is reachable, and the directory is exported. Try:

sudo showmount -e <nfs-server-ip>

Error: Permission Denied from Server

Double-check the subnet or IP permissions in /etc/exports. A mismatch will result in "Permission Denied."

3. NFS Performance Bottlenecks and How to Fix Them

Performance can degrade due to sync mode. Use async for speed, but only if you can tolerate some risk of data loss in case of a crash. Consider tuning mount options like rsize, wsize, and using NFSv4 for better performance and fewer open ports.

Best Practices for a Reliable NFS Setup

For a reliable NFS setup, you can practice the following principles:

  • Use static IPs or DNS entries for all clients in /etc/exports.
  • Prefer NFSv4 for better security and reduced port usage.
  • Secure your setup with firewall rules and user access controls.
  • Monitor your NFS server with tools like nfsstat and iotop.
  • Avoid exporting directories with high permission complexity (e.g., /home) unless you manage user ID consistency across nodes.

FAQ

How do I check if NFS is installed on Ubuntu?

Run dpkg -l | grep nfs or check services with systemctl status nfs-server.

Can I mount an NFS share on a Windows machine?

Yes, Windows 10 Pro and higher support NFS client features via the "Services for NFS" optional feature.

Why is my NFS mount read-only on Ubuntu?

Check the ro flag in /etc/exports and verify client mount options don’t enforce read-only.

How do I restart the NFS service on Ubuntu?

Use: sudo systemctl restart nfs-server.

How do I force an NFS unmount?

Run: sudo umount -f /mount/point.

Does NFS support encryption?

Not natively. For secure transport, use NFS over a VPN or configure it with Kerberos (NFSv4 with sec=krb5p).

How can I view active NFS connections?

Use ss -tulpn | grep nfs, netstat, or check with nfsstat and /var/log/syslog.

Share

Was this article helpful to you?

VPS popular offers

-18.6%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
4 TB
wKVM-SSD 4096 Metered Windows

38 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-KVM-SSD 16384 Linux

231 /mo

/mo

Billed annually

-7.9%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 8192 Windows

26.08 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
400 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 16384 Linux

50 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 4096 Linux

16.45 /mo

/mo

Billed annually

-9.5%

CPU
CPU
4 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-wKVM-SSD 8192 Windows

121.5 /mo

/mo

Billed annually

-10%

CPU
CPU
3 Epyc Cores
RAM
RAM
2 GB
Space
Space
20 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 2048 Linux

8.8 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
MT5 KVM 8192 Windows

29.99 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 8192 Linux

25.25 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 4096 Linux

15 /mo

/mo

Billed annually

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.