RHCSA Rapid Track
Configure the automounter with an indirect map, using exports from an NFSv4 server.
Outcomes
Install required packages to set up the automounter.
Configure an automounter indirect map, with resources from a preconfigured NFSv4 server.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This start script determines whether the servera and serverb systems are reachable on the network. The start script configures serverb as an NFSv4 server, sets up permissions, and exports directories. The script also creates users and groups that are needed on both servera and serverb systems.
[student@workstation ~]$ lab start netstorage-review
Instructions
An IT support company uses a central server, serverb, to host some exported directories on /shares for their groups and users. Users must be able to log in and have their exported directories mounted on demand and ready to use, in the /remote directory on servera.
The following list provides the environment characteristics for completing this exercise:
The
serverbmachine is sharing the/sharesdirectory, which in turn contains themanagement,production, andoperationsubdirectories.The
managersgroup consists of themanager1andmanager2users. Those users have read and write access to the/shares/managementexported directory.The
productiongroup consists of thedbuser1andsysadmin1users. Those users have read and write access to the/shares/productionexported directory.The
operatorsgroup consists of thecontractor1andconsultant1users. Those users have read and write access to the/shares/operationexported directory.The main mount point for
serverais the/remotedirectory.Use the
/etc/auto.master.d/shares.autofsfile as the master map file, and use the/etc/auto.sharesfile as the indirect map file.The
/shares/managementexported directory is automounted on/remote/managementonservera.The
/shares/productionexported directory is automounted on/remote/productiononservera.The
/shares/operationexported directory is automounted on/remote/operationonservera.All user passwords are set to
redhat.
Log in to
serveraand install the required packages.Log in to
serveraas thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Install the
autofspackage.[root@servera ~]#
dnf install autofs...output omitted... Is this ok [y/N]:y...output omitted... Complete!
Configure an automounter indirect map on
serverawith exports fromserverb. Create an indirect map with files that are named/etc/auto.master.d/shares.autofsfor the master map and/etc/auto.sharesfor the mapping file. Use the/remotedirectory as the main mount point onservera. Rebootserverato determine whether theautofsservice starts automatically.Test the NFS server before you configure the automounter.
[root@servera ~]#
mount -t nfs serverb.lab.example.com:/shares /mnt[root@servera ~]#ls -l /mnttotal 0 drwxrwx---. 2 root managers 25 Apr 4 01:13 management drwxrwx---. 2 root operators 25 Apr 4 01:13 operation drwxrwx---. 2 root production 25 Apr 4 01:13 production [root@servera ~]#umount /mntCreate a master map file named
/etc/auto.master.d/shares.autofs, insert the following content, and save the changes./remote /etc/auto.shares
Create an indirect map file named
/etc/auto.shares, insert the following content, and save the changes.* -rw,sync,fstype=nfs4 serverb.lab.example.com:/shares/&
Start and enable the
autofsservice onservera.[root@servera ~]#
systemctl enable --now autofsCreated symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
Test the
autofsconfiguration with the various users. When done, log out fromservera.Switch to the
manager1user and test access.[root@servera ~]#
su - manager1[manager1@servera ~]$ls -l /remote/management/total 4 -rw-r--r--. 1 root managers 46 Apr 4 01:13 Welcome.txt [manager1@servera ~]$cat /remote/management/Welcome.txt###Welcome to Management Folder on SERVERB### [manager1@servera ~]$echo TEST1 > /remote/management/Test.txt[manager1@servera ~]$cat /remote/management/Test.txtTEST1 [manager1@servera ~]$ls -l /remote/operation/ls: cannot open directory '/remote/operation/': Permission denied [manager1@servera ~]$ls -l /remote/production/ls: cannot open directory '/remote/production/': Permission denied [manager1@servera ~]$exitlogout [root@servera ~]#Switch to the
dbuser1user and test access.[root@servera ~]#
su - dbuser1[dbuser1@servera ~]$ls -l /remote/production/total 4 -rw-r--r--. 1 root production 46 Apr 4 01:13 Welcome.txt [dbuser1@servera ~]$cat /remote/production/Welcome.txt###Welcome to Production Folder on SERVERB### [dbuser1@servera ~]$echo TEST2 > /remote/production/Test.txt[dbuser1@servera ~]$cat /remote/production/Test.txtTEST2 [dbuser1@servera ~]$ls -l /remote/operation/ls: cannot open directory '/remote/operation/': Permission denied [dbuser1@servera ~]$ls -l /remote/management/ls: cannot open directory '/remote/management/': Permission denied [dbuser1@servera ~]$exitlogout [root@servera ~]#Switch to the
contractor1user and test access.[root@servera ~]#
su - contractor1[contractor1@servera ~]$ls -l /remote/operation/total 4 -rw-r--r--. 1 root operators 45 Apr 4 01:13 Welcome.txt [contractor1@servera ~]$cat /remote/operation/Welcome.txt###Welcome to Operation Folder on SERVERB### [contractor1@servera ~]$echo TEST3 > /remote/operation/Test.txt[contractor1@servera ~]$cat /remote/operation/Test.txtTEST3 [contractor1@servera ~]$ls -l /remote/management/ls: cannot open directory '/remote/management/': Permission denied [contractor1@servera ~]$ls -l /remote/production/ls: cannot open directory '/remote/production/': Permission denied [contractor1@servera ~]$exitlogout [root@servera ~]#Explore the
mountoptions for the NFS automounted export.[root@servera ~]#
mount | grep nfsrpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)serverb.lab.example.com:/shares/managementon/remote/managementtypenfs4(rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255, sync,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.10, local_lock=none,addr=172.25.250.11)serverb.lab.example.com:/shares/operationon/remote/operationtypenfs4(rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255, sync,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.10, local_lock=none,addr=172.25.250.11)serverb.lab.example.com:/shares/productionon/remote/productiontypenfs4(rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255, sync,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.10, local_lock=none,addr=172.25.250.11)Return to the
workstationmachine as thestudentuser.[root@servera ~]#
exitlogout [student@servera ~]$exitlogout Connection to servera closed.