RHCSA Practical Lab Series β Configuring AutoFS for NFS Mounts
π 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 operationsautofs
β 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! π