How to Mount an NFS Share in Linux

By 

Updated on

8 min read

Mount an NFS File System in Linux

When a file server or NAS on your network exports a directory over NFS, you can reach those files from another Linux machine as if they lived on a local disk. This is a common setup for shared backups, home directories, and project storage.

Network File System (NFS) is the distributed file system protocol that makes this possible. On Linux and Unix-like systems, the mount command attaches the remote NFS export to a local mount point in your directory tree. From there, you can access the remote files according to the permissions set on the server.

This guide explains how to mount an NFS share on Linux, both manually for a one-time mount and automatically through /etc/fstab so the share returns after a reboot.

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.

The command queries the server’s mount service, which an NFSv4-only server may not provide. If showmount -e returns no exports, confirm the export path on the server or try mounting the known NFSv4 path directly.

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. Systemd already recognizes NFS as a network filesystem, so this option is mainly useful for network-backed filesystems it cannot identify automatically.
  • x-systemd.automount — Create an automount unit and mount the share when you first access the path. This avoids delaying boot while an unavailable server times out.

A typical fstab entry for a reliable NFS mount:

/etc/fstabini
10.10.0.10:/backups /var/backups nfs defaults,nofail,x-systemd.automount 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. Unsaved writes may be lost, and the command can still hang when the server is unreachable.

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 server is not advertising an RPC service required for the requested NFS version. From the client, list the services registered on the server:

Terminal
rpcinfo -p 10.10.0.10

If the expected NFS, mountd, or rpcbind service is missing, check the server logs. On Fedora, RHEL, and derivatives, restart the NFS service with:

Terminal
sudo systemctl restart nfs-server

On Ubuntu, Debian, and derivatives, run:

Terminal
sudo systemctl restart nfs-kernel-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 . NFSv4 normally uses TCP port 2049. NFSv3 also relies on rpcbind, mountd, and other RPC services that may use additional ports, so configure fixed service ports on the server before adding firewall rules. 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 x-systemd.automount to the fstab options. nofail lets boot continue if the share cannot be mounted, while x-systemd.automount delays the connection until you access the mount point.

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. Add x-systemd.automount when you want the connection to start on first access instead of during boot. 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 query the server’s export list. An NFSv4-only server may not expose the mount service used by showmount, so an empty result does not always mean that no exports exist.

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 nofail, and use x-systemd.automount when the server may not be available during boot. 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