firoz@rhel:~$
all labs
Identity & AccessCompletedDecember 2025

Centralising Home Directories with NFS and autofs

Exported user home directories from a RHEL NFS server and mounted them on-demand on a client with autofs, with SELinux booleans set correctly instead of disabling the policy.

nfsautofsselinuxrhcsa

Environment

  • ›2x RHEL 9.4 VMs — nfs-server, nfs-client
  • ›Packages: nfs-utils, autofs
  • ›Shared network: 192.168.56.0/24

Objectives

  1. 01Export /home/guests from the server, restricted to the client's subnet
  2. 02Mount it on the client automatically on access using autofs, not a static fstab entry
  3. 03Get SELinux booleans right so NFS home directories actually work

Walkthrough

Step 1

Configure the NFS export

Created the export directory, added an entry to /etc/exports restricted to the lab subnet with root_squash, and exported it.

$ mkdir -p /home/guests
$ echo '/home/guests 192.168.56.0/24(rw,sync,root_squash)' >> /etc/exports
$ exportfs -arv
$ systemctl enable --now nfs-server

Step 2

Open the firewall for NFS

Used the predefined 'nfs' firewalld service rather than guessing ports, since NFS uses several auxiliary services (rpc-bind, mountd).

$ firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd}
$ firewall-cmd --reload

Step 3

Configure autofs on the client

Added a master map entry pointing /home/guests at an indirect map, so home directories mount on first access and unmount after a period of inactivity — instead of mounting everything at boot.

$ echo '/home/guests /etc/auto.guests' >> /etc/auto.master
$ echo '* -rw,sync nfs-server:/home/guests/&' >> /etc/auto.guests
$ systemctl enable --now autofs
$ ls /home/guests/alice

Step 4

Fix the SELinux boolean

The first login attempt failed with permission denied even though Unix permissions were fine. getsebool showed use_nfs_home_dirs was off — enabling it (persistently) fixed logins without touching enforcing mode.

$ getsebool use_nfs_home_dirs
$ setsebool -P use_nfs_home_dirs on

Outcomes

  • ✓Same home directory follows a user between two client VMs
  • ✓Learned to reach for setsebool -P before ever reaching for setenforce 0
  • ✓autofs idle-unmount behaviour confirmed with automount -m