On-Demand Mounting with autofs
One objective. The behaviour is the whole point and it is captured directly: findmnt reports nothing mounted, one ls runs, and findmnt reports an NFS mount that autofs created. Both map styles the exam can ask for - indirect and direct - are built here.
File Systems Guide 39 of 67 Intermediate
- OSRHEL 10.0
- Kernel6.12.0-55.9.1.el10_0
- dnf4.20.0
- Flatpak1.16.0
- TimeAbout 14 min
Put maps in /etc/auto.master.d/<name>.autofs rather than editing /etc/auto.master. The stock master file ends with +auto.master, which includes that directory, so a drop-in survives package updates and can be deleted cleanly.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RHCSA-A01 | 192.168.0.31 | RHEL 10.0 | Practice node (graded) - spare /dev/sda | 2 Core | 4 GB | 50 GB + 15 GB |
| RHCSA-UTIL01 | 192.168.0.32 | RHEL 10.0 | Utility - repository server and NFS exports | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when a mount should appear only once something asks for it. This matters because nothing is mounted until a path is looked at - and an autofs map replaces the fstab entry entirely.
- installing the package, and finding the map files
- writing an indirect map
- confirming nothing is mounted until something looks
- using both keys, with no fstab entry at all
- writing a direct map instead
Before you start
- A working NFS mount first -
guide 38. - The session installs
autofs, writes map files, and removes them.
-
The package and the map files
-
An indirect map
-
Nothing is mounted until something looks
-
Both keys, and no fstab at all
-
A direct map