Mount a Share in Three Commands
The examples use an NFS server at the private address 10.0.0.5 that exports /srv/share, and a client at 10.0.0.20. NFS traffic is not encrypted by default, so keep both servers on a private network and never expose NFS to the internet. The difference is explained in public vs private IP.
sudo mkdir -p /mnt/share
sudo mount -t nfs 10.0.0.5:/srv/share /mnt/share
df -h /mnt/shareInstall the Client Tools
| System | Command |
|---|---|
| Debian, Ubuntu | sudo apt install nfs- |
| AlmaLinux, Rocky Linux | sudo dnf install nfs- |
Without these packages, mount cannot find the NFS helper program and fails with a message about a wrong file system type or a bad option.
See What a Server Exports
showmount -e 10.0.0.5This lists the exported paths and which clients may mount them. It asks a helper service used by NFSv3; a server configured for NFSv4 only may not answer, even though mounting works.
Choose the NFS Version
Without a version option, the client tries NFS 4.2 first and steps down until it finds a version the server supports. To set it explicitly:
sudo mount -t nfs -o vers=4.2 10.0.0.5:/srv/share /mnt/shareNFSv4 needs only TCP port 2049, which makes the firewall simpler. NFSv3 also needs rpcbind on port 111 and further ports for its helper services. Check what is in use with nfsstat -m or findmnt /mnt/share.
Mount at Boot with fstab
A wrong line in /etc/fstab can stop a server from booting, so test it before any reboot. Add:
10.0.0.5:/srv/share /mnt/share nfs defaults,_netdev,nofail 0 0_netdev marks the mount as needing the network, so systemd mounts it after the network is up (it already treats the nfs type that way; the option makes it explicit), and nofail lets the boot continue if the NFS server is down. Then test:
sudo umount /mnt/share
sudo mount -a
findmnt /mnt/shareIf mount -a prints an error, fix the line before rebooting. Every field is explained in fstab explained.
A Short Server-Side Setup
On the server, install nfs-kernel-server on Debian and Ubuntu, which starts the service. On AlmaLinux and Rocky Linux, install nfs-utils and run sudo systemctl enable --now nfs-server. Export the folder to the one client that needs it, in /etc/exports:
/srv/share 10.0.0.20(rw,sync,no_subtree_check)Never export to * or a public range. Apply and check:
sudo exportfs -ra
sudo exportfs -vOpen the Firewall in the Safe Order
On the NFS server, allow NFS from the client's address only. With ufw, confirm SSH is allowed before you enable the firewall, so you do not lock yourself out:
sudo ufw allow OpenSSH
sudo ufw allow from 10.0.0.20 to any port 2049 proto tcp
sudo ufw enableWith firewalld, add the client to the internal zone and allow NFS there, leaving the public zone and its SSH rule unchanged:
sudo firewall-cmd --permanent --zone=internal --add-source=10.0.0.20/32
sudo firewall-cmd --permanent --zone=internal --add-service=nfs
sudo firewall-cmd --reloadThese rules cover NFSv4. NFSv3 also needs the rpc-bind and mountd services in firewalld, or port 111 and the mountd port in ufw. Test the mount from the client before you close your current session. More on each tool in how to set up a UFW firewall and how to use firewalld.
Common Errors
- Access denied by server while mounting: the export does not list the client's address, or
exportfs -rawas not run after editing. - Connection timed out: a firewall on either side or in your provider's network blocks port 2049, or the address is wrong.
- Permission denied when writing: by default root on the client is mapped to an unprivileged user (root squash), and file ownership follows numeric user IDs, so the same user needs the same UID on both servers.
- Stale file handle: the exported folder was replaced on the server. Unmount and mount again.
When the second machine is reachable only over SSH, SSHFS mounts a folder through the encrypted connection instead.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations