6. Create and Configure File Systems
πRed Hat Certified System Administrator (RHCSA β EX200)
Autofs is a Linux service that automatically mounts file systems when you need them and unmounts them after a period of inactivity. This is useful in IT environments where servers or workstations need access to network shares like NFS or SMB but you donβt want all shares mounted all the time.
Key Concepts for the Exam
- Purpose of autofs
- Automatically mounts file systems when accessed.
- Automatically unmounts them after a period of inactivity.
- Reduces system load by not keeping unused network file systems mounted.
- Helps prevent errors if network file systems are temporarily unavailable.
- Components of autofs
Autofs works using two main types of files: ComponentDescriptionMaster Map (/etc/auto.master)The main configuration file. It tells autofs which mount points to manage and what mapping files to use.Map Files (e.g.,/etc/auto.home,/etc/auto.nfs)Contains detailed instructions for each mount point, such as network path and options.autofs serviceThe running service that monitors the mount points and mounts/unmounts on demand.
How autofs Works
- You define a master map in
/etc/auto.master.
Example: /mnt/nfs /etc/auto.nfs/mnt/nfsβ the local directory where mounts will appear./etc/auto.nfsβ the map file containing details about remote file systems.
- You create the map file. Example
/etc/auto.nfs: projects -rw,soft server1:/exports/projects
backups -ro server2:/exports/backupsprojectsβ will appear under/mnt/nfs/projectswhen accessed.-rwβ mount options (read/write),-roβ read-only.softβ if server is unavailable, it wonβt hang the client.server1:/exports/projectsβ the remote NFS path.
- Start the autofs service: sudo systemctl enable autofs
sudo systemctl start autofs - Access the mount point: ls /mnt/nfs/projects
- Autofs automatically mounts the NFS share here when accessed.
- After a period of inactivity (default ~5 minutes), autofs automatically unmounts it.
Useful Commands
- Check status of autofs systemctl status autofs
- Restart autofs after config changes sudo systemctl restart autofs
- Debug autofs sudo automount -v
- Show active mounts managed by autofs mount | grep autofs
Common Mount Options in autofs Map Files
| Option | Meaning |
|---|---|
rw | Mount the file system read/write |
ro | Mount read-only |
soft | If the server fails, the mount times out instead of hanging |
hard | Client waits indefinitely for server response |
noauto | Prevent automatic mounting at boot; only mount on access |
Exam Tips
- You must know the locations of the main configuration files:
/etc/auto.masterβ master map- Map files like
/etc/auto.home,/etc/auto.nfsβ details for mounts
- Understand mount options like
rw,ro,soft,hard. - Be able to start, stop, enable, and restart the autofs service.
- Understand the concept: on-demand mounting and automatic unmounting.
- You may be asked to configure autofs for local NFS mounts, not just examples.
Example Scenario for Exam Practice
- Configure autofs to mount NFS shares from a server:
- Master map:
/etc/auto.master/mnt/nfs /etc/auto.nfs - Map file:
/etc/auto.nfsdevasc -rw,soft server:/exports/devasc
test -ro server:/exports/test - Enable and start autofs: sudo systemctl enable autofs
sudo systemctl start autofs - Access the mount: ls /mnt/nfs/devasc
- Master map:
This will ensure the NFS share is mounted only when you access /mnt/nfs/devasc and unmounted automatically after inactivity.
Summary for the Exam
- autofs automatically mounts/unmounts file systems on demand.
- Master map (
/etc/auto.master) defines directories and associated map files. - Map files define remote shares and mount options.
- Service commands:
systemctl start|stop|restart autofs. - Exam focus: configuring autofs for network shares (usually NFS), understanding map files, and using correct options.
