How to Mount an NFS Share in Linux

By 

Updated on

7 min read

Mount an NFS File System in Linux

Network File System (NFS) is a distributed file system protocol that enables sharing remote directories over a network. It allows you to mount remote directories on your system and interact with remote files as if they were local.

On Linux and Unix-like systems, the mount command attaches a shared NFS directory to a local mount point in your directory tree.

In this tutorial, we will show you how to mount an NFS share manually or automatically on Linux systems.

Quick Reference

TaskCommand
Install NFS client (Ubuntu, Debian)sudo apt install nfs-common
Install NFS client (Fedora, RHEL)sudo dnf install nfs-utils
List exports on NFS servershowmount -e SERVER_IP
Mount NFS sharesudo mount -t nfs SERVER:/export /mountpoint
Mount with optionssudo mount -t nfs -o rw,sync SERVER:/export /mnt
Verify mountmount | grep nfs
Unmount NFS sharesudo umount /mountpoint
Force unmountsudo umount -f /mountpoint
Lazy unmountsudo umount -l /mountpoint
Mount all fstab entriessudo mount -a

Installing NFS Client Packages

To mount an NFS share, you will first need to install the NFS client package. The package name varies between Linux distributions.

  • On Ubuntu, Debian, and Derivatives:

    Terminal
    sudo apt update
    sudo apt install nfs-common
  • On Fedora, RHEL, and Derivatives:

    Terminal
    sudo dnf install nfs-utils

Listing Available NFS Exports

Before mounting, you can check which directories the NFS server is exporting with the showmount command:

Terminal
showmount -e 10.10.0.10
output
Export list for 10.10.0.10:
/backups 10.10.0.0/24
/data    *

This shows the exported paths and the clients that are allowed to mount them. If showmount is not available, install it alongside the NFS client utilities.

Manually Mounting an NFS Share

Mounting a remote NFS share is the same as mounting any regular file system.

To mount an NFS file system on a given mount point, use the mount command in the following form:

txt
mount [OPTION...] NFS_SERVER:EXPORTED_DIRECTORY MOUNT_POINT

Here, NFS_SERVER:EXPORTED_DIRECTORY is the remote NFS export, and MOUNT_POINT is the local directory where you want to access it.

Follow these steps:

  1. Create a local directory to serve as the mount point:

    Terminal
    sudo mkdir /var/backups

    A mount point is a directory on the local machine where an NFS share is to be mounted.

  2. Mount the NFS share as root or a user with sudo privileges:

    Terminal
    sudo mount -t nfs 10.10.0.10:/backups /var/backups

    Here, 10.10.0.10 is the NFS server’s IP address, /backups is the exported directory, and /var/backups is the local mount point.

    On success, the command produces no output.

    Pass additional options with -o (for example, -o rw,sync). Multiple options are provided as a comma-separated list. To get a full list of options, type man mount in your terminal.

  3. To verify that the remote NFS volume is successfully mounted, use either the mount or df -h command:

    Terminal
    mount | grep nfs
    Terminal
    df -h

Once the share is mounted, the mount point becomes the root directory of the mounted filesystem.

When you manually mount the share, it does not persist after a reboot.

Automatically Mounting NFS Shares with /etc/fstab

For persistent mounts, configure automatic mounting on boot using the /etc/fstab file. This file contains a list of entries that define which filesystems are mounted on boot.

The line must include the hostname or the IP address of the NFS server, the exported directory, and the mount point on the local machine.

Steps to automatically mount an NFS share:

  1. Create a mount point if it does not already exist:

    Terminal
    sudo mkdir /var/backups
  2. Edit the /etc/fstab file with your text editor :

    Terminal
    sudo nano /etc/fstab

    Add this line:

    /etc/fstabini
    # <file system>     <dir>         <type>  <options>       <dump> <pass>
    10.10.0.10:/backups /var/backups  nfs     defaults,nofail 0      0

    Where 10.10.0.10 is the NFS server IP address, /backups is the exported directory, and /var/backups is the local mount point. The nofail option prevents the system from halting at boot if the NFS server is unreachable.

  3. Mount the share immediately without rebooting:

    Terminal
    sudo mount /var/backups

    Alternatively, mount all entries defined in /etc/fstab at once:

    Terminal
    sudo mount -a

    The mount command reads the contents of /etc/fstab and mounts the share.

Next time you reboot the system, the NFS share will be mounted automatically.

NFS Mount Options

Common options you can pass with -o or add to the /etc/fstab entry:

  • rw / ro — Mount read-write (default) or read-only.
  • sync / async — Write operations wait for acknowledgment from the server (sync) or are buffered locally (async). sync is safer; async is faster.
  • noexec — Prevent execution of binaries on the mounted filesystem.
  • nofail — Do not report an error if the device does not exist at boot. Useful for NFS shares that may not be available immediately.
  • vers=4 / vers=3 — Force a specific NFS protocol version. NFSv4 is the default on modern systems.
  • _netdev — Mark the filesystem as requiring network access. Ensures the system waits for the network before mounting.

A typical fstab entry for a reliable NFS mount:

/etc/fstabini
10.10.0.10:/backups /var/backups nfs defaults,nofail,_netdev 0 0

Unmounting NFS Shares

To detach a mounted NFS share, use the umount command followed by either the local mount point or the remote share:

Terminal
sudo umount /var/backups

If the share is defined in the fstab file, remove the entry to prevent remounting on boot.

The umount command will fail if the mounted volume is in use. To find out which processes are accessing the NFS share, use the fuser command:

Terminal
fuser -m /var/backups

Stop them with the kill command, then retry.

If you still have problems unmounting the share, use the -l (--lazy) option, which allows you to unmount a busy file system as soon as it becomes available:

Terminal
sudo umount -l /var/backups

If the remote server is unreachable, use the -f (--force) option to force an unmount:

Terminal
sudo umount -f /var/backups

Avoid the force option when possible, as it may corrupt the file system.

Troubleshooting

“Permission denied”
The directory may not be correctly exported on the server. Check /etc/exports on the NFS server and run sudo exportfs -ar to reload exports. The client IP address must also be listed in the export entry.

“RPC: Program not registered”
The NFS service is not running on the remote server. Restart it with:

Terminal
sudo systemctl restart nfs-server

“Stale file handle”
This occurs after the server reboots or a file is deleted while mounted. Unmount and remount the share on the client to resolve it.

“Server not responding” or connection timeout
Check network connectivity using ping and traceroute . Ensure firewall rules allow traffic on ports 111 and 2049. If the NFS version is mismatched, specify vers=3 or vers=4 explicitly in the mount options.

System halts at boot when NFS server is unavailable
Add nofail and _netdev to the fstab options. nofail prevents a boot failure if the share cannot be reached, and _netdev ensures the mount waits for the network to be ready.

FAQ

What is the difference between NFS v3 and NFS v4?
NFSv4 is the modern standard and includes built-in security (Kerberos support), stateful operations, and better firewall compatibility (single port 2049). NFSv3 uses multiple ports and requires portmapper (port 111). Most modern Linux distributions default to NFSv4. Use vers=3 in mount options only if the server does not support v4.

How do I automatically mount an NFS share at boot?
Add an entry to /etc/fstab with the NFS server path, local mount point, type nfs, and options including nofail and _netdev. Run sudo mount -a to test the entry before rebooting.

Why does the NFS mount not persist after a reboot?
Manual mounts with mount -t nfs are not persistent. To keep a mount across reboots, add the entry to /etc/fstab as described in the Automatically Mounting section.

How do I check which NFS shares are available on a server?
Use showmount -e SERVER_IP to list the directories the server is exporting and which clients are allowed to access them.

What does the nofail option do in fstab?
nofail tells the system not to report an error and not to halt the boot process if the filesystem cannot be mounted. This is especially useful for network filesystems like NFS that may not be available immediately at boot time.

Conclusion

Mounting an NFS share on Linux requires installing the client utilities, creating a local mount point, and running mount -t nfs. For persistent mounts, add the entry to /etc/fstab with the nofail and _netdev options to ensure reliable boot behavior. To learn more about general filesystem mounting, see the mount command guide .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page