RH134 Ch 7: NFS and autofs

NFS lets a client mount a directory exported by a server as if it were local. RHEL uses NFSv4 by default.

Finding exports. showmount -e serverb lists exports (NFSv3 servers); with NFSv4 you can also mount the server's root and browse it.

Manual and persistent mounts.

bash mkdir /mnt/shared mount -t nfs serverb:/exports/shared /mnt/shared

For boot, add an fstab line; netdev tells systemd to wait for the network:

serverb:/exports/shared /mnt/shared nfs defaults,netdev 0 0

Common options: rw/ro, sync, vers=4.2, sec=sys. Test with mount -a and check with findmnt -t nfs4 or mount | grep nfs.

autofs mounts shares only when someone touches the path and unmounts them after a period of idleness — handy for home directories. Install autofs, then systemctl enable --now autofs.

A master map entry in /etc/auto.master.d/<name.autofs points a base directory at a map file.

Indirect map — keys are created under a base directory:

/etc/auto.master.d/homes.autofs /remote /etc/auto.homes /etc/auto.homes -rw,sync serverb:/exports/homes/&

matches any name and & reuses it, so /remote/student1 mounts …/homes/student1.

Direct map — full paths anywhere in the tree, using the special key /-:

/etc/auto.master.d/direct.autofs /- /etc/auto.direct /etc/auto.direct /projects/docs -ro serverb:/exports/projects

Restart autofs after editing maps. Indirect mount points do not appear in ls /remote until accessed — cd into them by name.

Common exam mistakes - Creating the indirect sub-directories by hand (autofs makes them). - Forgetting systemctl enable, so automounts vanish after reboot. - A master map file not ending in .autofs, so it is ignored. - Mixing up rw and ro or leaving out the options dash: -rw.