NFS: mount, showmount, rpcinfo, nfsstat, exportfs, mountstats, nfsiostat, nfsd (2/2)
Part 2 of the NFS toolkit: rpcinfo asks a server's rpcbind which RPC programs live on which port, nfsstat / mountstats / nfsiostat read the local kernel's NFS counters, and exportfs (Linux) or nfsd (macOS) manage the server side. Together they are how you debug a missing or slow NFS mount.
161.1 Why is it used?
- rpcinfo: check over the network that nfs (100003) and mountd (100005) are registered with rpcbind (port 111) and actually answer.
- nfsstat: NFS/RPC call counters and retransmissions of the local client or server kernel.
- mountstats / nfsiostat: per-mount statistics (ops/s, kB/s, RTT, retrans) to find which mount is slow.
- exportfs (Linux) / nfsd (macOS): show and change what the server exports, and apply edits to /etc/exports.
- macOS mount_nfs -o options tune read/write sizes, attribute caching and locking.
161.2 How it works
- rpcbind (portmapper) listens on port 111 and maps RPC program numbers to ports; rpcinfo -p dumps that map.
- A "null call" (procedure 0) is an RPC ping: "ready and waiting" means the service answers.
- nfsstat, mountstats and nfsiostat send nothing on the network: they read /proc/net/rpc/nfs and /proc/self/mountstats.
- So they show data only when the kernel NFS client is loaded and an NFS mount is active.
- exportfs edits the kernel nfsd's export table (/var/lib/nfs/etab); a userspace server like unfsd ignores it.
- Lab: client 192.168.181.20, server 192.168.181.10 running rpcbind + unfsd (userspace NFSv3), no kernel NFS modules loaded.
- Step 1
1.client 192.168.181.20 runs rpcinfo -p 192.168.181.10
- Step 2
2.PMAP DUMP goes through the switch to rpcbind on port 111
- Step 3
3.Server replies: 100003 nfs and 100005 mountd, both on port 2049
- Step 4
4.client runs rpcinfo -T tcp 192.168.181.10 nfs 3
- Step 5
5.Null call (procedure 0) goes to port 2049
- Step 6
6.Reply: program 100003 version 3 ready and waiting
rpcinfo talks to the server; nfsstat/mountstats only read the local kernel
161.3 macOS mount_nfs: sizes, caching, locking and deprecated flags
- No Mac in the lab: these come from the macOS docs, syntax only.
- rsize / wsize set the size of one read/write RPC (default 8192 UDP, 32768 TCP); dsize is the directory read size.
- ac* options set attribute cache seconds; actimeo sets all of them, noac turns the cache off.
- locallocks keeps v2/v3 locks local; nolocks / nolockd / nolock / nonlm disable locking.
- Old single-letter flags are deprecated: replace them with -o names in old scripts.
mount -t nfs -o OPTS server:/export ~/mnt/nfsrsize= wsize= rwsize= read / write sizedsize=32768 directory read size default 8192 UDP, 32768 TCPreadahead=16 read-ahead RPCs (0-128)rdirplus | nordirplus ReaddirPlus on / offacregmin=5,acregmax=60 files: cache secactimeo=10 | noac all timeouts | cache offlocallocks v2/v3: locks only localnolocks|nolockd|nolock|nonlm no locks| Deprecated flag | -o replacement | Deprecated flag | -o replacement |
|---|---|---|---|
| -2 / -3 / -4 | vers=2 / vers=3 / vers=4 | -L | nolocks |
| -T | tcp | -U | mntudp |
| -s | soft | -i | intr |
| -b | bg | -P | resvport |
| -r 32768 | rsize= | -w 32768 | wsize= |
| -t 20 | timeo= | -x 5 | retrans= |
161.4 rpcinfo -p, -s, -m (query rpcbind)
- Plain rpcinfo with no host asks the local rpcbind: the client runs none, so a real error.
- -p host: portmapper v2 list (program, version, proto, port).
- -s host: concise form with all versions, netids and owner.
- -m host: rpcbind call counters (SET, GETPORT, DUMP, CALLIT...).
rpcinforpcinfo -p 192.168.181.10rpcinfo -s 192.168.181.10rpcinfo -m 192.168.181.10$ rpcinforpcinfo: can't contact rpcbind: RPC: Remote system error - No such file or directory$ rpcinfo -p 192.168.181.10 program vers proto port service 100000 4 tcp 111 100000 2 udp 111 100003 3 udp 2049 100003 3 tcp 2049 100005 1 udp 2049 100005 3 udp 2049 100005 1 tcp 2049 100005 3 tcp 2049$ rpcinfo -s 192.168.181.10 program version(s) netid(s) service owner 100000 2,3,4 local,udp,tcp,udp6,tcp6 - superuser 100003 3 tcp6,tcp,udp6,udp - superuser 100005 3,1 tcp6,tcp,udp6,udp - superuser- The service column is empty because Alpine has no /etc/rpc, so names fail too.
- After writing a 4-line /etc/rpc, names work and -p shows service names.
rpcinfo -T tcp 192.168.181.10 nfs 3ls -l /etc/rpc# lab: 4 lines written to /etc/rpccat /etc/rpcrpcinfo -T tcp 192.168.181.10 nfs 3$ rpcinfo -T tcp 192.168.181.10 nfs 3rpcinfo: nfs is unknown service$ ls -l /etc/rpcls: /etc/rpc: No such file or directory$ cat /etc/rpcrpcbind 100000 portmap sunrpcnfs 100003 nfsprogmountd 100005 mount showmountnlockmgr 100021program 100003 version 3 ready and waiting161.5 rpcinfo null calls, -a, -l and real errors
- -T udp host mountd (no version) pings every version: v2 came back "not available".
- nfs 4 is missing because unfsd serves only NFSv3.
- -u / -t are the old UDP/TCP null calls; -n 2049 skips rpcbind and uses the port directly.
- -a uses a universal address: last two numbers are the port, 8 x 256 + 1 = 2049.
- "Program not registered" for nlockmgr: unfsd registers no lock manager. An empty IP gives "Host is unreachable".
rpcinfo -T udp 192.168.181.10 mountdrpcinfo -T tcp 192.168.181.10 nfs 4rpcinfo -a 192.168.181.10.8.1 -T tcp nfs 3rpcinfo -T tcp 192.168.181.10 nlockmgr 4rpcinfo -T tcp 192.168.181.30 nfs 3$ rpcinfo -T udp 192.168.181.10 mountdprogram 100005 version 1 ready and waitingrpcinfo: RPC: Program/version mismatch; low version = 1, high version = 3program 100005 version 2 is not availableprogram 100005 version 3 ready and waiting$ rpcinfo -T tcp 192.168.181.10 nfs 4rpcinfo: RPC: Program/version mismatch; low version = 3, high version = 3program 100003 version 4 is not available$ rpcinfo -a 192.168.181.10.8.1 -T tcp nfs 3program 100003 version 3 ready and waiting$ rpcinfo -T tcp 192.168.181.10 nlockmgr 4rpcinfo: RPC: Program not registered$ rpcinfo -T tcp 192.168.181.30 nfs 3rpcinfo: RPC: Remote system error - Host is unreachable161.6 rpcinfo -b broadcast and -d
- -b sends a CALLIT for a program/version to the subnet broadcast (192.168.181.255:111) so every server can answer.
- In the lab tcpdump saw 4 packets go out but no reply came; timeout 6 stopped rpcinfo (exit 143).
- The server's rpcinfo -m showed CALLIT 2/2, so the call did arrive.
- -d program version (run as owner/root on the server) unregisters a program, here mountd v1.
- Step 1
1.client runs timeout 6 rpcinfo -b mountd 3
- Step 2
2.CALLIT mountd v3 sent to 192.168.181.255 port 111
- Step 3
3.switch forwards the broadcast to every host
- Step 4
4.server rpcbind receives it: CALLIT counter 2/2
- Step 5
5.no reply reaches the client
- Step 6
6.timeout kills rpcinfo after 6 s (exit 143)
tcpdump -n -i eth0 -c 4 'udp port 111' &timeout 6 rpcinfo -b mountd 3rpcinfo -m 192.168.181.10 | sed -n '1,9p'# server:rpcinfo -d 100005 1$ timeout 6 rpcinfo -b mountd 307:59:41.603287 IP 192.168.181.20.60935 > 192.168.181.255.111: UDP, length 13207:59:41.603484 IP 192.168.181.20.60935 > 192.168.181.255.111: UDP, length 13207:59:41.603888 IP 192.168.181.20.60935 > 192.168.181.255.111: UDP, length 13207:59:41.603927 IP 192.168.181.20.60935 > 192.168.181.255.111: UDP, length 132Terminated(rpcinfo exit 143)$ rpcinfo -m 192.168.181.10 | sed -n '1,9p'PORTMAP (version 2) statisticsNULL SET UNSET GETPORT DUMP CALLIT0 0/0 0/0 0/0 2 2/2PMAP_RMTCALL call statisticsprog vers proc netid success failuremountd 3 0 udp 2 0| rpcinfo option | What it does |
|---|---|
| rpcinfo [host] | Full dump: netid + universal address |
| -p host | Portmapper v2 list |
| -s host | Concise: versions, owner |
| -m host | rpcbind statistics |
| -T tcp host P [V] | Null call (procedure 0); without V on udp pings all versions |
| -l host P V | All transports of one program/version |
| -u / -t host P [V] | UDP / TCP null call (obsolete) |
| -n 2049 -t ... | Skip rpcbind, use this port |
| -a h.8.1 -T tcp P V | Ping a universal address (port 8x256+1) |
| -b P V | Broadcast to all hosts |
| -d P V | Unregister (owner/root) |
| macOS -b / -h | IPv6 multicast FF02::202 + UDP broadcast / print synopsis |
161.7 nfsstat (Linux and macOS)
- On the lab client every nfsstat form errors: /proc/net/rpc/nfs does not exist (kernel NFS client not loaded).
- nfsstat -m is empty (exit 0) because there is no NFS mount.
- nfs-cat (userspace libnfs) read the file fine, yet nfsstat -c still saw nothing: userspace traffic is not counted.
nfsstatnfsstat -sls /proc/net/rpcnfsstat -mnfs-cat nfs://192.168.181.10/srv/nfs/release.txtnfsstat -c$ nfsstatError: No Client Stats (/proc/net/rpc/nfs: No such file or directory).$ nfsstat -sError: No Server Stats (/proc/net/rpc/nfsd: No such file or directory).$ ls /proc/net/rpcauth.unix.gidauth.unix.ip$ nfsstat -m(exit 0)$ nfs-cat nfs://192.168.181.10/srv/nfs/release.txtbuild v2.0 ok$ nfsstat -c| Need | Linux nfsstat | macOS nfsstat |
|---|---|---|
| Client / server only | -c / -s | -c / -s |
| Mounts and their flags | -m | -m [~/mnt/nfs] |
| One NFS version | -2 / -3 / -4 | -c -3 / -c -4 |
| RPC retransmissions / network | -o rpc / -o net | -E (protocol errors) |
| Live rate | -c -Z5 (every 5 sec) | -w 2 (summary every 2 sec) |
| Server caches | -s -o fh / -o rc | -e (exported-directory stats) |
| Other | -S FILE (diff from file) | -f JSON, -u (active users), sudo nfsstat -z (zero) |
161.8 mountstats and nfsiostat (per mount)
- Both read /proc/self/mountstats; in the lab it has 0 NFS entries, so both say "No NFS mount points were found".
- mountstats has 3 sub-commands: mountstats (default), nfsstat, iostat.
- mountstats -S FILE gives the delta from an old snapshot to now; -f after -S before compares two saved files.
- nfsiostat: first report covers time since mount, later reports only the interval.
- nfsiostat columns: op/s, rpc bklog, kB/s, kB/op, retrans, avg RTT, avg exe, avg queue, errors.
grep -c 'fstype nfs' /proc/self/mountstatsmountstatsmountstats iostat 5 2nfsiostat 5 2 /mnt/nfsnfsiostat --version$ grep -c 'fstype nfs' /proc/self/mountstats0$ mountstatsNo NFS mount points were found$ nfsiostatNo NFS mount points were found$ nfsiostat --versionversion 0.2| Option | mountstats | nfsiostat |
|---|---|---|
| Interval / count | iostat 5 [10] | 5 [12] |
| One mount | mountstats /mnt/nfs | nfsiostat 5 /mnt/nfs |
| Filter output | -n NFS, -r RPC, -x transport | -a attr cache, -d dir ops, -p page cache |
| Snapshots / sort | -S FILE, -f FILE, -R raw | -s sort by ops/s, -l 3 first 3 mounts |
161.9 exportfs (Linux) and nfsd (macOS)
- exportfs -v shows the current export list with options; empty at first.
- exportfs -rav re-reads /etc/exports, writes etab, drops removed entries (warns when subtree_check is not specified).
- -s prints the list in /etc/exports format.
- -o opts host:/path exports without editing the file; -u host:/path unexports one, -ua all.
- Defaults: sync, ro, root_squash, wdelay.
cat /etc/exportsexportfs -ravexportfs -o ro,no_subtree_check 192.168.181.20:/srv/isoexportfs -u 192.168.181.20:/srv/build# client:showmount -e 192.168.181.10[srv]$ cat /etc/exports/srv/nfs 192.168.181.0/24(ro)/srv/build 192.168.181.20(rw,no_root_squash)[srv]$ exportfs -ravexportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.181.0/24:/srv/nfs". Assuming default behaviour ('no_subtree_check').exporting 192.168.181.20:/srv/buildexporting 192.168.181.0/24:/srv/nfs[client]$ showmount -e 192.168.181.10Export list for 192.168.181.10:/srv/nfs 192.168.181.0/24/srv/build 192.168.181.20- showmount still lists /srv/build after exportfs -u: exportfs changes only the kernel nfsd table, unfsd reads /etc/exports itself.
- macOS nfsd: enable/disable survives reboot, start/stop is for now only, update reloads exports, checkexports reports errors, settings live in /etc/nfs.conf.
- macOS nfsd extras: -p 2050 NFS port (default 2049), -n 16 threads (default 8), -t / -u TCP or UDP only.
161.10 Common mistakes
- Thinking an nfsstat error means the server is down: it only reads the local kernel counters.
- Expecting nfsstat/mountstats to count userspace (libnfs) traffic or to work with no mount.
- Forgetting exportfs -ra after editing /etc/exports on a kernel NFS server.
- Using deprecated mount_nfs single-letter flags instead of -o option=value.
- Expecting rpcinfo names to work without /etc/rpc.
161.11 Interview tips
- Debugging a slow NFS mount: rpcinfo -p (nfs + mountd registered), then rpcinfo -T tcp host nfs 3 (ready and waiting).
- Next nfsstat -o rpc for retransmissions, then nfsiostat 5 / mountstats for per-mount RTT and slow ops.
- Growing retrans or avg RTT points to the network or the server, not the client.
- Know the numbers: rpcbind 111, NFS 2049, program 100003 nfs, 100005 mountd, 100021 nlockmgr.