RHCSA Practical Lab Series – Configuring AutoFS for NFS Mounts

Expertise in Cloud, Networking & DevOps
Photo by Kevin Ku / Unsplash

πŸ” Lab 8: Setting Up AutoFS for Network File System (NFS) Mounts

πŸ“Œ Objective

In this lab, you will:

βœ” Install and configure AutoFS to automatically mount an NFS share
βœ” Ensure that remoteuser1’s home directory is automatically mounted at /rhome/remoteuser1
βœ” Enable persistent mounting with read-write (rw) permissions
βœ” Verify and troubleshoot AutoFS behavior


πŸ“Œ Step 1: Install Required Packages

πŸ”Ή Ensure NFS and AutoFS utilities are installed:

[root@node1 ~]# yum -y install nfs-utils
[root@node1 ~]# yum -y install autofs

πŸ“Œ Explanation:

  • nfs-utils β†’ Provides support for NFS client operations
  • autofs β†’ Enables automatic mounting of remote file systems

πŸ“Œ Step 2: Configure AutoFS Master File

πŸ”Ή Edit the AutoFS master configuration file:

[root@node1 ~]# vim /etc/auto.master

πŸ”Ή Add the following line at the end of the file:

/rhome  /etc/auto.rhome

πŸ“Œ Explanation:

  • /rhome β†’ This is the base mount point for AutoFS.
  • /etc/auto.rhome β†’ Specifies the map file that defines the NFS mounts.

πŸ“Œ Step 3: Define NFS Mount Points in AutoFS

πŸ”Ή Edit the AutoFS map file for /rhome:

[root@node1 ~]# vim /etc/auto.rhome

πŸ”Ή Add the following entry:

remoteuser1 -rw materials.cloudnetops.tech:/rhome/remoteuser1

πŸ“Œ Explanation:

  • remoteuser1 β†’ This subdirectory will be mounted dynamically.
  • -rw β†’ Grants read-write access to the mounted directory.
  • materials.cloudnetops.tech:/rhome/remoteuser1 β†’ Specifies the NFS export location.

πŸ“Œ Step 4: Start and Enable AutoFS

πŸ”Ή Enable and start the AutoFS service:

[root@node1 ~]# systemctl enable --now autofs

πŸ“Œ Tip: The --now flag starts the service immediately and enables it at boot time.

πŸ”Ή Verify AutoFS is running:

[root@node1 ~]# systemctl status autofs

πŸ“Œ Step 5: Verify Auto-Mounted Directories

πŸ”Ή List the /rhome directory (should be empty until accessed):

[root@node1 ~]# ls /rhome/

πŸ“Œ Expected Output:

(no output – directory appears empty)

πŸ”Ή Trigger the AutoFS mount by accessing the directory:

[root@node1 ~]# ls /rhome/remoteuser1

πŸ“Œ Expected Output (if successful):

lost+found  documents  configs

βœ… If files appear, AutoFS successfully mounted the NFS share!


πŸ“Œ Step 6: Verify User Access

πŸ”Ή Switch to remoteuser1 and check the working directory:

[root@node1 ~]# su - remoteuser1
[remoteuser1@node1 ~]$ pwd

πŸ“Œ Expected Output:

/rhome/remoteuser1

πŸ”Ή Test file creation inside the mounted directory:

[remoteuser1@node1 ~]$ touch testfile.txt

βœ… If the file is created without errors, the mount has read-write permissions.


πŸ“Œ Step 7: Verify the Mounted File System

πŸ”Ή Check active mounts for /rhome:

[root@node1 ~]# mount | grep rhome

πŸ”Ή Expected Output:

materials.cloudnetops.tech:/rhome/remoteuser1 on /rhome/remoteuser1 type nfs4 (rw,relatime,vers=4.2,soft,timeo=600,retrans=2)

βœ… If this appears, AutoFS successfully mounted the NFS share.

πŸ“Œ Troubleshooting:

If ls /rhome/remoteuser1 does not show files, check for firewall or NFS server issues:

[root@node1 ~]# showmount -e materials.cloudnetops.tech

If the directory does not mount automatically, restart AutoFS:

[root@node1 ~]# systemctl restart autofs

βœ… Final Summary

βœ” Installed AutoFS and NFS utilities
βœ” Configured AutoFS master and map files
βœ” Enabled automatic mounting for /rhome/remoteuser1
βœ” Verified AutoFS is correctly mounting the NFS share


πŸ“Œ Next Lab: Creating a User with a Specific UID

πŸ“© Subscribe for more RHCSA exam labs and hands-on tutorials! πŸš€


Read more