Mounting and Unmounting Network File System : A Practical Guide

Published On: 27 May 2025

Objective

In today’s enterprise environments, unified file sharing between systems is essential. Whether you’re a seasoned Linux administrator or a budding RHCSA aspirant, understanding how to mount and unmount a Network File System (NFS) is a fundamental skill that cannot be overlooked. This blog offers a hands-on tutorial for setting up, configuring, mounting, and unmounting NFS shares on Linux systems — with a focus on RHCSA exam preparation.

It covers:

  • Why NFS is useful: Centralized storage, reduced duplication, and easier backups.

  • Practical implementation: Commands to configure an NFS server and mount on clients.

  • Key configurations: Permissions, exports, and security features.

What Is a Network File System (NFS)?

NFS (Network File System) is a distributed file system protocol that allows a system to share directories and files with others over a network. It enables clients to mount remote directories on their local machines and interact with them as though they are part of the local filesystem.

Why Is NFS Important?

From development environments to enterprise file servers, NFS simplifies resource sharing. Here’s why it’s widely used in Linux environments:

  • Centralized storage access: Files are stored in a single location and accessed over the network.

  • Reduced data duplication: Files are stored once and shared, saving disk space.

  • Simplified backups and maintenance: Backup and maintenance tasks can be centralized.

  • Cross-platform compatibility: NFS is supported across Linux, BSD, Solaris, macOS, and more.

Prerequisites

To follow along with this guide, you need:

  • Two Linux systems (client and server)

  • Root or sudo privileges

  • NFS utilities installed

Step 1: Installing NFS Utilities

  • On both server and client machines:

sudo dnf install nfs-utils -y          # Install NFS utilities
  • Enable and start the NFS server (on the server side):

sudo systemctl enable --now nfs-server # Enable and start the NFS server immediately
  • Or start it without enabling on boot:

sudo systemctl start nfs-server        # Start the NFS server (non-persistent)

Step 2: Configuring the NFS Server

Let’s say you want to share the /srv/nfs/shared directory.

  • Create the directory:

sudo mkdir -p /srv/nfs/shared          # Create directory for NFS sharing
  • Set ownership (for RHEL/CentOS):

sudo chown nfsnobody:nfsnobody /srv/nfs/shared   # Assign generic ownership
  • Set permissions:

chmod 755 /srv/nfs/shared        # Set appropriate directory permissions
  • Edit the exports file:

sudo nano /etc/exports               # Open exports configuration file
  • Add:

/srv/nfs/shared 192.168.122.0/24(rw,sync,no_root_squash)  # Define NFS share and access control
  • Export the directory:

sudo exportfs -rav              # Apply export changes immediately 
  • Verify the export:

sudo exportfs -v             # View active NFS exports
  • Allow NFS through the firewall:

sudo firewall-cmd --add-service=nfs --permanent  # Allow NFS traffic permanently
sudo firewall-cmd --reload               # Reload firewall to apply changes

Step 3: Mounting the NFS Share on the Client

  • Create a mount point:

sudo mkdir -p /mnt/nfs/shared           # Create local mount directory
  • Mount the share:

sudo mount -t nfs 192.168.122.10:/srv/nfs/shared /mnt/nfs/shared # Mount the remote NFS share
  • Verify the mount:

df -h | grep nfs        # Display mounted NFS shares with size info

or

mount | grep nfs            # Check current mount points for NFS

Step 4: Making the Mount Permanent

  • Edit /etc/fstab:

sudo nano /etc/fstab             # Edit file to add permanent mount
  • Add:

192.168.122.10:/srv/nfs/shared /mnt/nfs/shared nfs defaults 0 0  #Persistent NFS mount entry
  • Test it:

sudo mount -a                 # Test all fstab entries for correct mounting

Step 5: Unmounting an NFS Share

  • To unmount:

sudo umount /mnt/nfs/shared           # Unmount NFS share
  • If the directory is in use:

lsof +D /mnt/nfs/shared             # Identify processes using the mount
  • Terminate any process using the directory, then unmount.

Common NFS Troubleshooting

  • "Permission denied" when mounting

    • Check /etc/exports for syntax issues.

    • Confirm firewall settings.

    • If SELinux is enabled, use:

      sudo setsebool -P use_nfs_home_dirs 1           # Adjust SELinux for NFS home directory access
  • Mount hangs or times out

    • Check if the NFS server is running:

      sudo systemctl status nfs-server            # Verify NFS server status
  • Mount not persistent after reboot

    • Recheck your /etc/fstab entry for typos.

    • Use sudo mount -a to test it.

NFS Security Best Practices

  • Restrict access with firewalls to trusted IPs.

  • Enable root_squash to prevent root privilege escalation.

  • Don’t expose sensitive directories unless necessary.

  • For secure environments, use NFSv4 with Kerberos authentication.

How This Ties Into the RHCSA Exam

RHCSA candidates are expected to:

  • Mount/unmount NFS shares (temporary and permanent)

  • Use /etc/fstab for configuration

  • Set permissions and troubleshoot NFS issues

Practice is key. RHCSA.GURU offers real-world scenarios and labs to reinforce your learning.

Conclusion

Mounting and unmounting NFS shares is a core skill for any Linux administrator — and essential for RHCSA success. It’s about more than commands; it’s about understanding how systems share resources efficiently. Get hands-on experience, practice in test environments, and don’t fear making mistakes. That’s how real learning — and real confidence — is built.