Hostxpeed
Login Get Started →
Server Management

How to Set Up NFS Share

6 min read
26 views
Jun 12, 2026

Prerequisites

Before setting up NFS, make sure you have:

  • Two or more VPS servers
  • Root or sudo privileges on both
  • Network connectivity between servers

Part 1: Configure NFS Server

Connect to your NFS server VPS:

ssh hxroot@SERVER_IP -p 22

Install NFS server:

sudo apt update
sudo apt install nfs-kernel-server -y

Create directory to share:

sudo mkdir -p /srv/nfs_share
sudo chown nobody:nogroup /srv/nfs_share
sudo chmod 755 /srv/nfs_share

Create test file:

echo "Hello from NFS server" | sudo tee /srv/nfs_share/test.txt

Configure exports:

sudo nano /etc/exports

Add:

/srv/nfs_share CLIENT_IP(rw,sync,no_subtree_check)

For multiple clients:

/srv/nfs_share 192.168.1.0/24(rw,sync,no_subtree_check)

Apply exports:

sudo exportfs -a
sudo systemctl restart nfs-kernel-server

Allow firewall (NFS uses port 2049):

sudo ufw allow from CLIENT_IP to any port nfs
# Also allow rpcbind
sudo ufw allow 111/tcp
sudo ufw allow 111/udp

Part 2: Configure NFS Client

Connect to your client VPS:

ssh hxroot@CLIENT_IP -p 22

Install NFS client:

sudo apt install nfs-common -y

Create mount point:

sudo mkdir -p /mnt/nfs_share

Mount NFS share:

sudo mount -t nfs SERVER_IP:/srv/nfs_share /mnt/nfs_share

Verify:

ls -la /mnt/nfs_share
cat /mnt/nfs_share/test.txt

Write test from client:

echo "Written from client" | sudo tee /mnt/nfs_share/client_test.txt

Back on server, verify file appears.

Auto-mount on Client Boot (fstab)

sudo nano /etc/fstab
SERVER_IP:/srv/nfs_share /mnt/nfs_share nfs defaults 0 0

NFS Options Explained

  • rw – Read/write access
  • sync – Write changes to disk before replying
  • no_subtree_check – Improves reliability
  • no_root_squash – Allows root access from clients (use with caution)
  • ro – Read-only access

Check NFS Exports

sudo exportfs -v

View NFS Mounts on Client

mount | grep nfs

Unmount NFS Share

sudo umount /mnt/nfs_share

Troubleshooting NFS

Check server logs:

sudo journalctl -u nfs-kernel-server -n 50

Check if NFS is listening:

sudo netstat -tulpn | grep 2049

Test from client:

showmount -e SERVER_IP

✅ NFS share configured. Files can now be shared between servers.

Was this article helpful?