Red Hat System Administration II
Create direct-mapped and indirect-mapped automount-managed mount points that mount NFS file systems.
Outcomes
Install required packages for the automounter.
Configure direct and indirect automounter maps, with resources from a preconfigured NFSv4 server.
Describe the difference between direct and indirect automounter maps.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This start script determines whether servera and serverb are reachable on the network. The script alerts you if those servers are not available. 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.
[student@workstation ~]$ lab start netstorage-autofs
Instructions
An internet service provider uses a central server, serverb, to host shared directories with important documents that must be available on demand. When users log in to servera, they need access to the automounted shared directories.
The following list provides the environment characteristics for completing this exercise:
The
serverbmachine exports the/shares/indirectdirectory, which in turn contains thewest,central, andeastsubdirectories.The
serverbmachine also exports the/shares/direct/externaldirectory.The
operatorsgroup consists of theoperator1andoperator2users. They have read and write access to the/shares/indirect/west,/shares/indirect/central, and/shares/indirect/eastexported directories.The
contractorsgroup consists of thecontractor1andcontractor2users. They have read and write access to the/shares/direct/externalexported directory.The expected mount points for
serveraare/externaland/internal.The
/shares/direct/externalexported directory is automounted onserverawith a direct map on/external.The
/shares/indirect/westexported directory is automounted onserverawith an indirect map on/internal/west.The
/shares/indirect/centralexported directory is automounted onserverawith an indirect map on/internal/central.The
/shares/indirect/eastexported directory is automounted onserverawith an indirect map on/internal/east.All user passwords are set to
redhat.The
nfs-utilspackage is already installed.
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 direct map on
serverawith exports fromserverb. Create the direct map with files that are named/etc/auto.master.d/direct.autofsfor the master map and/etc/auto.directfor the mapping file. Use the/externaldirectory as the main mount point onservera.Test the NFS server and export before you configure the automounter.
[root@servera ~]#
mount -t nfs \serverb.lab.example.com:/shares/direct/external /mnt[root@servera ~]#ls -l /mnttotal 4 -rw-r--r--. 1 root contractors 22 Apr 7 23:15 README.txt [root@servera ~]#umount /mntCreate a master map file named
/etc/auto.master.d/direct.autofs, insert the following content, and save the changes./- /etc/auto.direct
Create a direct map file named
/etc/auto.direct, insert the following content, and save the changes./external -rw,sync,fstype=nfs4 serverb.lab.example.com:/shares/direct/external
Configure an automounter indirect map on
serverawith exports fromserverb. Create the indirect map with files that are named/etc/auto.master.d/indirect.autofsfor the master map and/etc/auto.indirectfor the mapping file. Use the/internaldirectory as the main mount point onservera.Test the NFS server and export before you configure the automounter.
[root@servera ~]#
mount -t nfs \serverb.lab.example.com:/shares/indirect /mnt[root@servera ~]#ls -l /mnttotal 0 drwxrws---. 2 root operators 24 Apr 7 23:34 central drwxrws---. 2 root operators 24 Apr 7 23:34 east drwxrws---. 2 root operators 24 Apr 7 23:34 west [root@servera ~]#umount /mntCreate a master map file named
/etc/auto.master.d/indirect.autofs, insert the following content, and save the changes./internal /etc/auto.indirect
Create an indirect map file named
/etc/auto.indirect, insert the following content, and save the changes.* -rw,sync,fstype=nfs4 serverb.lab.example.com:/shares/indirect/&
Start the
autofsservice onservera, and enable it to start automatically at boot time.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 direct automounter map as the
contractor1user. When done, exit from thecontractor1user session onservera.Switch to the
contractor1user.[root@servera ~]#
su - contractor1[contractor1@servera ~]$List the
/externalmount point.[contractor1@servera ~]$
ls -l /externaltotal 4 -rw-r--r--. 1 root contractors 22 Apr 7 23:34 README.txtReview the content and test the access to the
/externalmount point.[contractor1@servera ~]$
cat /external/README.txt###External Folder### [contractor1@servera ~]$echo testing-direct > /external/testing.txt[contractor1@servera ~]$cat /external/testing.txttesting-directExit from the
contractor1user session.[contractor1@servera ~]$
exitlogout [root@servera ~]#
Test the indirect automounter map as the
operator1user. When done, log out fromservera.Switch to the
operator1user.[root@servera ~]#
su - operator1[operator1@servera ~]$List the
/internalmount point.[operator1@servera ~]$
ls -l /internaltotal 0Note
With an automounter indirect map, you must access each exported subdirectory for them to mount. With an automounter direct map, after you access the mapped mount point, you can immediately view and access the subdirectories and content in the exported directory.
Test the
/internal/westautomounter exported directory access.[operator1@servera ~]$
ls -l /internal/west/total 4 -rw-r--r--. 1 root operators 18 Apr 7 23:34 README.txt [operator1@servera ~]$cat /internal/west/README.txt###West Folder### [operator1@servera ~]$echo testing-1 > /internal/west/testing-1.txt[operator1@servera ~]$cat /internal/west/testing-1.txttesting-1 [operator1@servera ~]$ls -l /internaltotal 0 drwxrws---. 2 root operators 24 Apr 7 23:34 westTest the
/internal/centralautomounter exported directory access.[operator1@servera ~]$
ls -l /internal/centraltotal 4 -rw-r--r--. 1 root operators 21 Apr 7 23:34 README.txt [operator1@servera ~]$cat /internal/central/README.txt###Central Folder### [operator1@servera ~]$echo testing-2 > /internal/central/testing-2.txt[operator1@servera ~]$cat /internal/central/testing-2.txttesting-2 [operator1@servera ~]$ls -l /internaltotal 0 drwxrws---. 2 root operators 24 Apr 7 23:34 central drwxrws---. 2 root operators 24 Apr 7 23:34 westTest the
/internal/eastautomounter exported directory access.[operator1@servera ~]$
ls -l /internal/easttotal 4 -rw-r--r--. 1 root operators 18 Apr 7 23:34 README.txt [operator1@servera ~]$cat /internal/east/README.txt###East Folder### [operator1@servera ~]$echo testing-3 > /internal/east/testing-3.txt[operator1@servera ~]$cat /internal/east/testing-3.txttesting-3 [operator1@servera ~]$ls -l /internaltotal 0 drwxrws---. 2 root operators 24 Apr 7 23:34 central drwxrws---. 2 root operators 24 Apr 7 23:34 east drwxrws---. 2 root operators 24 Apr 7 23:34 westTest the
/externalautomounter exported directory access.[operator1@servera ~]$
ls -l /externalls: cannot open directory '/external': Permission deniedReturn to the
workstationmachine as thestudentuser.[operator1@servera ~]$
exitlogout [root@servera ~]#exitlogout [student@servera ~]$exitlogout Connection to servera closed.