AlmaLinux 9: NFS export and mount (tested on one host)
Test scope
Section titled “Test scope”On a real AlmaLinux 9.8 host (kernel 5.14.0-687.54.1.el9_8): enabled nfs-server, wrote /etc/exports.d/lab.exports, ran exportfs -ra, exportfs -v, showmount -e 127.0.0.1, mount -t nfs 127.0.0.1:/srv/nfslab /mnt/nfslab, findmnt, df -hT, created a file, unmounted and cleaned up. Log: plans/content-expansion/evidence/logs/alma-nfs-mount.log.
Cross-host mounts, firewall rules for 2049 and autofs were not tested here (this was a loopback test on one host).
What a loopback mount can prove
Section titled “What a loopback mount can prove”Mounting the host’s own export through 127.0.0.1 validates the protocol and server configuration: the export is active, showmount sees it, the client mounts it as nfs4, and read/write works. It cannot validate the network path (firewall, routing, cross-host latency) — that needs a second machine.
Put the export in exports.d
Section titled “Put the export in exports.d”sudo systemctl enable --now nfs-serversudo mkdir -p /srv/nfslab && sudo chmod 777 /srv/nfslabecho "/srv/nfslab 127.0.0.1(rw,sync,no_root_squash)" | sudo tee /etc/exports.d/lab.exportssudo exportfs -ra/etc/exports.d/*.exports is equivalent to /etc/exports and easier to manage per purpose; after editing you must run exportfs -ra.
Check the export and mount it
Section titled “Check the export and mount it”sudo exportfs -vshowmount -e 127.0.0.1/srv/nfslab 127.0.0.1(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)Export list for 127.0.0.1:/srv/nfslab 127.0.0.1Mount and confirm the filesystem type:
sudo mkdir -p /mnt/nfslabsudo mount -t nfs 127.0.0.1:/srv/nfslab /mnt/nfslabfindmnt -no SOURCE,FSTYPE,TARGET /mnt/nfslabdf -hT /mnt/nfslab | tail -1127.0.0.1:/srv/nfslab nfs4 /mnt/nfslab127.0.0.1:/srv/nfslab nfs4 39G 2.4G 37G 6% /mnt/nfslabFSTYPE is nfs4, not nfs — NFSv4 is what gets negotiated by default. Verify read/write:
sudo touch /mnt/nfslab/hello && ls -l /mnt/nfslab/hello-rw-r--r-- 1 root root 0 Oct 19 13:30 /mnt/nfslab/helloCleanup order
Section titled “Cleanup order”sudo umount /mnt/nfslabsudo rm -f /etc/exports.d/lab.exportssudo exportfs -rasudo systemctl disable --now nfs-serverUnmount first, then withdraw the export, then stop the service. Reversing the order leaves a mount whose export is gone and unmounting reports device is busy.
Common traps
Section titled “Common traps”- Editing exports without
exportfs -ra:showmountnever shows the new directory; - Cross-host mounts blocked by the firewall: allow
nfs(2049/tcp) and, for v3, the mountd/rpc-bind ports — a loopback test cannot reveal this; - Treating
no_root_squashas default: it gives the client’s root server-side root; keep root squash unless you truly need otherwise.
Practice: export and mount on one host
Section titled “Practice: export and mount on one host”sudo systemctl enable --now nfs-serversudo mkdir -p /srv/nfslab && sudo chmod 777 /srv/nfslabecho "/srv/nfslab 127.0.0.1(rw,sync)" | sudo tee /etc/exports.d/lab.exportssudo exportfs -rasudo mkdir -p /mnt/nfslab && sudo mount -t nfs 127.0.0.1:/srv/nfslab /mnt/nfslabfindmnt -no FSTYPE /mnt/nfslab # expected nfs4sudo touch /mnt/nfslab/x && ls /mnt/nfslabsudo umount /mnt/nfslabChecks:
showmount -e 127.0.0.1→ lists/srv/nfslabfindmnt -no FSTYPE /mnt/nfslab→nfs4- A file can be created inside the mount
- After unmounting,
findmnt /mnt/nfslabprints nothing
常见问题
Why does FSTYPE show nfs4 instead of nfs?
NFSv4 is the default negotiated version, so mount -t nfs uses nfs4. Forcing v3 requires -o vers=3 and also opening the dynamic mountd/rpc-bind ports.
Loopback mount works but a remote host times out?
Loopback bypasses the firewall. A remote mount needs nfs (2049/tcp) allowed, plus mountd/rpc-bind for v3. Add firewall-cmd --add-service=nfs on the server and retry.
What if unmounting reports device is busy?
Find what is using the mount (lsof +D /mnt/nfslab or fuser -vm), leave the directory and retry. umount -l defers the cleanup — know that it delays rather than solves the problem.
Next steps
Section titled “Next steps”- Growing storage: LVM growth and XFS
- Post-install checks: 7 checks after install
- Auditing sources: Package source audit