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

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • Buy SSL Certificates
  • Blog
  • OpenSSL
  • Keytool
  • SSL Tools
  • Donate

How to mount NFS share on Linux

February 28, 2023 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

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

Conclusion – How to mount NFS share on Linux

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

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

Training Courses

Top online courses in IT & Software

Cyber Security Training

Udemy - The Complete Internet Security Privacy Course icon

Buy SSL Certificates

The SSL Store

Comodo Store

Sectigo Store

RapidSSL

Recent Posts

  • How to mount NFS share on Linux
  • DNS Powershell
  • Ansible Create VM VMware
  • Perl send email windows
  • httpd SELinux

Footer

  • Twitter
  • YouTube

Pages

  • About Mister PKI
  • Blog
  • Compare and Buy Affordable PKI Certificates
  • Contact Us
  • Full Disclosure
  • Privacy Policy
  • SSL Tools – Certificate Decoder and Certificate Checker

Copyright © 2023