Tutorial 10 min read by syncopio Team

Setting Up NFS Exports: Complete Configuration Guide

Master /etc/exports syntax, security options, and performance tuning. Platform-specific instructions for Ubuntu, Synology DSM, QNAP QTS, and TrueNAS.

NFS exports are the foundation of Linux file sharing. Whether you’re setting up a new file server, configuring a NAS appliance for migration, or troubleshooting mount failures, understanding /etc/exports is essential. This guide covers the syntax, security options, performance tuning, and platform-specific instructions.

NFS Basics

NFS (Network File System) allows a server to share directories over the network. Clients mount these shared directories as if they were local filesystems.

Components:

  • Server — exports directories via /etc/exports
  • Client — mounts exports via mount -t nfs
  • Protocols — NFSv3 (stateless, UDP/TCP) and NFSv4 (stateful, TCP only)

/etc/exports Syntax

The export file defines what directories are shared and with what permissions:

/path/to/export    client(options)

Basic Examples

# Share /data with a single host
/data    192.168.1.100(rw,sync,no_subtree_check)

# Share with an entire subnet
/data    192.168.1.0/24(rw,sync,no_subtree_check)

# Share with multiple clients (different options)
/data    192.168.1.0/24(rw,sync) 10.0.0.0/8(ro,sync)

# Share with any client (use cautiously)
/data    *(ro,sync,no_subtree_check)

# Share with a hostname or DNS pattern
/data    client.example.com(rw,sync)
/data    *.example.com(ro,sync)

Watch the spacing

There must be no space between the client specification and the opening parenthesis. 192.168.1.0/24(rw) is correct. 192.168.1.0/24 (rw) exports to everyone with rw and to the subnet with default (ro) — a common and dangerous mistake.

Export Options

Read/Write Options

OptionDescription
rwRead-write access
roRead-only access (default)
syncReply only after changes committed to disk (safe, default)
asyncReply before changes committed (faster but risks data loss on crash)

User Mapping Options

OptionDescription
root_squashMap root (UID 0) to nobody (default, recommended)
no_root_squashAllow root access as root (dangerous)
all_squashMap all users to nobody
anonuid=NSet the UID for anonymous/squashed users
anongid=NSet the GID for anonymous/squashed users

When to use no_root_squash

Only disable root squashing when the client genuinely needs root access — for example, a backup server that must preserve ownership across all files. For migration tools like syncopio, no_root_squash ensures permissions are preserved correctly during transfer.

Subtree Options

OptionDescription
subtree_checkVerify files are in the exported subtree (slower, more secure)
no_subtree_checkSkip subtree verification (faster, recommended for most cases)

NFSv4 Options

OptionDescription
fsid=0Mark as NFSv4 pseudo-root filesystem
crossmntAllow traversal of mount points within the export
sec=krb5Require Kerberos authentication
sec=krb5iKerberos + integrity checking
sec=krb5pKerberos + privacy (encryption)

Platform-Specific Setup

Ubuntu / Debian

# Install NFS server
sudo apt update
sudo apt install nfs-kernel-server

# Create export directory
sudo mkdir -p /srv/data
sudo chown nobody:nogroup /srv/data

# Configure exports
echo '/srv/data  192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)' | sudo tee -a /etc/exports

# Apply changes
sudo exportfs -ra

# Verify
sudo exportfs -v

# Start and enable
sudo systemctl enable --now nfs-kernel-server

RHEL / Rocky Linux / AlmaLinux

# Install NFS server
sudo dnf install nfs-utils

# Configure exports
sudo vi /etc/exports
# /srv/data    192.168.1.0/24(rw,sync,no_subtree_check)

# Apply and start
sudo exportfs -ra
sudo systemctl enable --now nfs-server

# Firewall rules
sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --permanent --add-service=mountd
sudo firewall-cmd --permanent --add-service=rpc-bind
sudo firewall-cmd --reload

Synology DSM

  1. Open Control Panel > File Services > NFS
  2. Enable NFS service (select NFSv4.1 for best performance)
  3. Go to Shared Folders, select a folder, click Edit
  4. Open the NFS Permissions tab
  5. Click Create and configure:
    • Hostname/IP: 192.168.1.0/24
    • Privilege: Read/Write
    • Squash: Map root to admin (or no mapping)
    • Security: sys (or krb5 if using Kerberos)
    • Enable asynchronous for better performance (if acceptable risk)
Synology DSM — NFS Permission Rule
Hostname/IP192.168.1.0/24
PrivilegeRead/Write
SquashMap root to admin
Securitysys
AsyncEnabled
Synology DSM NFS permission configuration for a shared folder

QNAP QTS

  1. Open Control Panel > Network & File Services > NFS Service
  2. Enable NFS and select the NFS version
  3. Go to Shared Folders, select the folder, click Edit Shared Folder Permission
  4. Switch to NFS Host Access tab
  5. Add a rule:
    • Access Right: Read/Write
    • Host/IP: 192.168.1.0/24
    • Squash: ROOT_SQUASH or NO_ROOT_SQUASH

TrueNAS

  1. Navigate to Sharing > Unix Shares (NFS)
  2. Click Add
  3. Configure:
    • Path: Select the dataset
    • Networks: 192.168.1.0/24
    • Maproot User: root (for migration) or nobody
    • Maproot Group: wheel or nobody
  4. Click Submit
  5. Enable the NFS service under Services

Performance Tuning

Server-Side

# Increase NFS daemon threads (default is often 8)
# For busy servers, use 32-64
echo 64 > /proc/fs/nfsd/threads

# Or set permanently in /etc/nfs.conf
[nfsd]
threads = 64

# Monitor current NFS statistics
nfsstat -s

Client-Side Mount Options

# High-performance mount
mount -t nfs4 server:/export /mnt -o \
  rsize=1048576,\        # 1MB read size
  wsize=1048576,\        # 1MB write size
  nconnect=8,\           # 8 TCP connections (Linux 5.3+)
  hard,\                 # Retry indefinitely on failure
  intr,\                 # Allow interrupt during retry
  noatime,\              # Don't update access times
  nocto                  # Don't refresh on open (read-heavy workloads)
OptionImpactWhen to Use
nconnect=NBiggest single improvement; N TCP connections per mountAlways (Linux 5.3+)
rsize/wsize=1MLarger I/O operations = fewer round-tripsLarge file workloads
noatimeSkip atime updates = fewer writesRead-heavy workloads
noctoSkip revalidation on open = faster opensWhen data rarely changes

nconnect is a game-changer

A single NFS TCP connection typically maxes out at ~3-4 Gbps due to head-of-line blocking. With nconnect=8, you can saturate a 10Gbps or even 25Gbps link. This is the single most impactful mount option for throughput.

Troubleshooting

Essential Diagnostic Commands

# Show current exports
exportfs -v

# Show what the client sees as available
showmount -e server

# Check RPC services are running
rpcinfo -p server

# Test NFS mount
mount -t nfs4 -v server:/export /mnt

# Check NFS statistics
nfsstat -c     # Client stats
nfsstat -s     # Server stats

# Debug mount issues
mount -t nfs4 -v -o nfsvers=4 server:/export /mnt 2>&1

Common Issues

ProblemCauseFix
”mount.nfs: access denied”Client IP not in export listCheck /etc/exports, run exportfs -ra
”mount.nfs: Connection timed out”Firewall blocking NFS portsOpen ports 2049 (NFS), 111 (rpcbind)
“Permission denied” on filesroot_squash or UID mismatchUse no_root_squash or map UIDs
Stale file handleExport was changed while mountedRemount on client: umount /mnt && mount ...
Very slow performanceDefault mount optionsAdd nconnect=8,rsize=1048576,wsize=1048576
”Program not registered”NFS server not runningsystemctl start nfs-server

Firewall Ports

For NFS to work across firewalls:

ServicePortProtocol
NFS2049TCP (v4), TCP/UDP (v3)
rpcbind111TCP/UDP
mountdDynamic*TCP/UDP
statdDynamic*TCP/UDP

*For NFSv3 with firewalls, set static ports in /etc/nfs.conf:

[mountd]
port = 20048

[statd]
port = 32765

NFSv4 only needs port 2049 — one of its advantages over v3.

Further Reading

Ready to simplify your migrations?

See how syncopio can save you hours on every migration project.

Request a Demo