• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • PKI Training
  • OpenSSL
  • Keytool
  • PKI Tools
    • Apereo CAS
    • SAML
    • OpenID Connect
  • Get expert help

How to mount NFS share on Linux

August 5, 2024 by Mister PKI Leave a Comment

This article will demonstrate how to mount an NFS share on Linux. The instructions will work for both Redhat and Ubuntu Operating Systems.

First, let’s define NFS. NFS stands for Network File System, which is a distributed file system protocol that allows you to share a directory over the network. These shares can be mounted on a file system and act the same as a local drive on the OS.

Install NFS Packages

First, you will need to install any required nfs packages.

Ubuntu

apt update
apt install nfs-common

Redhat

dnf install nfs-utils

Manual NFS mount

The steps assume root privileges.

  1. Create a directory for the location of the mount for the NFS share
mkdir /mount/mountA
  1. Mount the NFS share to the directory created in the previous step
mount -t nfs 10.10.0.0:/mountA /mount/mountA

A few things to note:

  • -t nfs means “type” nfs. While mount can usually detect the type, we recommend explicitly stating it.
  • 10.10.0.0:/mountA is the NFS server and and name of the share or directory the NFS server is exporting. You can also use the FQDN hostname instead of the IP address.
  • /mount/mountA is the mount point on the local server.
  1. Verify the mount was successful. The output should show the mount.
df -h

For more uses of the df command, we have written another article you may find useful.

Note: Remember this is a temporary mount that will NOT persist after a reboot. To create a persistent mount, proceed to the next section on using /etc/fstab.

Persistent NFS mount

While a temporary mount may be useful, a persistent mount that automatically mounts after a reboot will be the most common. For this we will be modifying the /etc/fstab directory to define the persistence.

The format of the /etc/fstab file is as follows:

<file system> <dir> <type> <options> <dump> <pass>
  • file system – NFS server IP address or FQDN hostname and exported directory
  • dir – The local mounting point
  • type – Type of mount, in this case will be nfs
  • options – defaults is okay for this example
  • dump – 1 means backup with the dump utility, 0 means disable.
  • pass – 0 to disable checking

To play on the manual mount example in the previous section, the fstab line should look like the following.

10.10.0.0:/mountA /mount/mountA nfs defaults 0 0

Now by running the mount command the mount will go into affect, and we subsequently be mounted on each reboot.

mount

or…

mount -a

Unmount NFS mount on Linux

Now that you have learned how to mount an NFS share on Linux, lets dive into how to unmount it.

First, to unmount an NFS share that was manually mounted, run the following command.

umount 10.10.0.0:/mountA

Or… unmount by pointing to the directory on the local host

umount /export/mount

If the mount was defined in /etc/fstab it will be re-mounted on the next reboot. So if you want the mount to be permanently removed, remove the line in the fstab file.

If the file is in use when trying to unmount the share, you will have to kill the process accessing the NFS share. The path given in the command is the local mount point. Additionally -f can be used to force the unmount.

fuser -m /mount/mountA

NFS mount is backgrounding

If you encounter an error stating the NFS mount is backgrounding, check the logs in /var/log/messages for more information. The error condition could be any of the following:

Connection time out: Ensure that the nfs server is reachable and has nfs installed with ports 111 and/or 2049 open.

Connection refused: Ensure the server has nfs installed with ports 111 and/or 2049 open.

In either case it may be necessary to restart the nfs process on the nfs server.

Start nfs

systemctl start nfs

Enable nfs to start after reboot

systemctl enable nfs

Stop nfs

systemctl stop nfs

Restart nfs

systemctl restart nfs

NFS Mount Timing Out

You may notice the nfs mount is timing out when performing the df -h command and it hangs.

df -h

If on Ubuntu, the /var/log/syslog file may contain this error message. If on Redhat, /var/log/messages may contain a similar error message giving you a clue that the connection is timing out.

You will also notice the nfs mount is timing out if a reboot fails to succeed. The reboot will wait on the mount to unmount. To fix this, you must first lazily unmount the nfs volume before performing the reboot. Use this command to perform a lazy unmount of the filesystem.

umount -l /mount-path

Conclusion – How to mount NFS share on Linux

If you encounter an error message stating NFS mount is backgrounding, check the logs in the /var/log/messages directory.

This article has demonstrated how to mount an NFS share on Linux. Leave us a comment with any questions or let us know if you would like to see more examples of how to mount or manage mounts for NFS on Linux.

Read more of our articles on Linux.

Read more of our content.

linux,  redhat,  Ubuntu

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

PKI for DevOps Engineers – Free Training Series

PKI for DevOps Training Hub

Lesson 1 – How TLS and PKI Work

Lesson 2 – Understanding X.509 Certificates

Lesson 3 – Certificate Chains Explained

Lesson 4 – Debug TLS with OpenSSL

Lesson 5 – Verify Certificate Chains

Lesson 6 – Creating CSRs with OpenSSL

Lesson 7 – Working with PKCS12 Certificates

Lesson 8 – Java Keystores and keytool

Lesson 9 – Certificate Expiration Monitoring

Lesson 10 – Automating Certificate Renewal

Lesson 11 – Common TLS Errors

Lesson 12 – PKI Architecture for DevOps

Recent Posts

  • Apache mod_auth_cas: Protect Web Applications with Apereo CAS and Docker
  • Apache mod_auth_mellon: Configure SAML SSO & Docker
  • Configure OpenID Connect (OIDC) in Apereo CAS 7.3 and 8
  • Certificate Ownership Is an Operating Model Problem, Not a Tooling Problem
  • OpenSSL dgst: Create Checksums and Verify Digital Signatures

Footer

  • Twitter
  • YouTube
Mister PKI

Practical security engineering for the systems that establish trust.

Learn OpenSSL Keytool Free training
Work together PKI consulting CAS consulting Sponsored contributions
Site About Support Mister PKI Cookie policy Search
© 2026 Mister PKI Secure systems. Clear guidance.