Skip to content
Search AlmaLinux

    Browse this documentation

    AlmaLinux 9: NFS export and mount (tested on one host)

    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).

    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.

    Terminal window
    sudo systemctl enable --now nfs-server
    sudo mkdir -p /srv/nfslab && sudo chmod 777 /srv/nfslab
    echo "/srv/nfslab 127.0.0.1(rw,sync,no_root_squash)" | sudo tee /etc/exports.d/lab.exports
    sudo exportfs -ra

    /etc/exports.d/*.exports is equivalent to /etc/exports and easier to manage per purpose; after editing you must run exportfs -ra.

    Terminal window
    sudo exportfs -v
    showmount -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.1

    Mount and confirm the filesystem type:

    Terminal window
    sudo mkdir -p /mnt/nfslab
    sudo mount -t nfs 127.0.0.1:/srv/nfslab /mnt/nfslab
    findmnt -no SOURCE,FSTYPE,TARGET /mnt/nfslab
    df -hT /mnt/nfslab | tail -1
    127.0.0.1:/srv/nfslab nfs4 /mnt/nfslab
    127.0.0.1:/srv/nfslab nfs4 39G 2.4G 37G 6% /mnt/nfslab

    FSTYPE is nfs4, not nfs — NFSv4 is what gets negotiated by default. Verify read/write:

    Terminal window
    sudo touch /mnt/nfslab/hello && ls -l /mnt/nfslab/hello
    -rw-r--r-- 1 root root 0 Oct 19 13:30 /mnt/nfslab/hello
    Terminal window
    sudo umount /mnt/nfslab
    sudo rm -f /etc/exports.d/lab.exports
    sudo exportfs -ra
    sudo systemctl disable --now nfs-server

    Unmount 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.

    • Editing exports without exportfs -ra: showmount never 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_squash as default: it gives the client’s root server-side root; keep root squash unless you truly need otherwise.
    Terminal window
    sudo systemctl enable --now nfs-server
    sudo mkdir -p /srv/nfslab && sudo chmod 777 /srv/nfslab
    echo "/srv/nfslab 127.0.0.1(rw,sync)" | sudo tee /etc/exports.d/lab.exports
    sudo exportfs -ra
    sudo mkdir -p /mnt/nfslab && sudo mount -t nfs 127.0.0.1:/srv/nfslab /mnt/nfslab
    findmnt -no FSTYPE /mnt/nfslab # expected nfs4
    sudo touch /mnt/nfslab/x && ls /mnt/nfslab
    sudo umount /mnt/nfslab

    Checks:

    1. showmount -e 127.0.0.1 → lists /srv/nfslab
    2. findmnt -no FSTYPE /mnt/nfslab → nfs4
    3. A file can be created inside the mount
    4. After unmounting, findmnt /mnt/nfslab prints 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.