Chapter 19: Network file systems and autofs

NFS and autofs cheat sheet

The chapter on one page: what to remember, the commands to have at your fingertips, and flashcards for quick revision.

The chapter in eight sentences

Cheat sheet

Server

CommandDoes
/srv/shared 172.25.250.0/24(rw,sync)A line in /etc/exports
exportfs -ra · exportfs -vApply and list the exports
systemctl enable --now nfs-serverStart the server
firewall-cmd --permanent --add-service=nfs · --reloadOpen the port
ro · rw · root_squash · no_root_squashCommon options

Client

CommandDoes
mount -t nfs serverb:/srv/shared /mnt/sharedMount
findmnt -t nfs4 · nfsstat -mShow NFS mounts
umount /mnt/sharedUnmount
ls -lnShow raw UIDs
fstabserverb:/srv/shared /mnt/shared nfs defaults,_netdev 0 0

autofs

ItemDoes
dnf install autofs · systemctl enable --now autofsInstall and start
/etc/auto.master.d/NAME.autofs/mnt/auto /etc/auto.NAME
map linekey -rw,sync serverb:/srv/dir
wildcard* -rw,sync serverb:/srv/homes/&
direct mapmaster /- /etc/auto.direct, key a full path
systemctl reload autofs · automount -mReload, show loaded maps

Flashcards

Server side in four steps?
mkdir share · /etc/exports line · systemctl enable --now nfs-server · exportfs -rav; firewall nfs service
An exports line?
/srv/shared 172.25.250.0/24(rw,sync) — path, host(options)
Show exports?
exportfs -v (server) · showmount -e SERVER (needs NFSv3 ports)
Client mount?
mount -t nfs server:/srv/shared /mnt/shared · df -hT · nfsstat -m
Permanent client mount?
server:/srv/shared /mnt/shared nfs defaults,_netdev 0 0
What crosses NFS?
Numeric UIDs and GIDs; use the same numbers on both sides.
root_squash?
Client root becomes nobody on the server (default). Fix permissions, not the squash.
No route to host / access denied / Permission denied?
Firewall / exports / UIDs and modes
Install and start autofs?
dnf install autofs · systemctl enable --now autofs · reload after edits
Indirect map?
/etc/auto.master.d/x.autofs: /mnt/auto /etc/auto.x --timeout=20 · /etc/auto.x: key -rw server:/dir
Wildcard home directories?
* -rw,sync server:/srv/homes/&
Direct map and checking?
/- /etc/auto.direct with full paths · automount -m · journalctl -u autofs