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
- NFS lets a client mount a directory that lives on a server; the server lists it in
/etc/exports, runsnfs-serverand opens thenfsfirewall service. - An exports line is
path host(options); apply changes withexportfs -raand check withexportfs -v. - Mount with
mount -t nfs serverb:/srv/shared /mnt/shared; NFSv4 needs only TCP port 2049. - The server decides access by numeric user ID, so the same UID must mean the same person on both machines.
root_squash(the default) turns the client's root into an unprivileged user;roexports refuse all writes.- Permanent mount: an fstab line
serverb:/srv/shared /mnt/shared nfs defaults,_netdev 0 0, tested withmount -a. - autofs mounts on first use and unmounts after a timeout: a master entry in
/etc/auto.master.d/NAME.autofspoints to a map file. - Wildcard map
* -rw,sync serverb:/srv/homes/&serves many directories; a direct map uses/-and full paths; reload withsystemctl reload autofs.
Cheat sheet
Server
| Command | Does |
|---|---|
/srv/shared 172.25.250.0/24(rw,sync) | A line in /etc/exports |
exportfs -ra · exportfs -v | Apply and list the exports |
systemctl enable --now nfs-server | Start the server |
firewall-cmd --permanent --add-service=nfs · --reload | Open the port |
ro · rw · root_squash · no_root_squash | Common options |
Client
| Command | Does |
|---|---|
mount -t nfs serverb:/srv/shared /mnt/shared | Mount |
findmnt -t nfs4 · nfsstat -m | Show NFS mounts |
umount /mnt/shared | Unmount |
ls -ln | Show raw UIDs |
| fstab | serverb:/srv/shared /mnt/shared nfs defaults,_netdev 0 0 |
autofs
| Item | Does |
|---|---|
dnf install autofs · systemctl enable --now autofs | Install and start |
/etc/auto.master.d/NAME.autofs | /mnt/auto /etc/auto.NAME |
| map line | key -rw,sync serverb:/srv/dir |
| wildcard | * -rw,sync serverb:/srv/homes/& |
| direct map | master /- /etc/auto.direct, key a full path |
systemctl reload autofs · automount -m | Reload, 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