14.1 Mount and Unmount Network File Systems Using NFS
Key Takeaways
- Mount NFS shares with mount -t nfs (or mount.nfs) using server:/export /mountpoint; unmount with umount when the share is idle.
- Persist NFS mounts in /etc/fstab with type nfs (or nfs4), options such as defaults,_netdev, and dump/pass fields 0 0 so mounts survive reboot after the network is up.
- Discover exports with showmount -e server when the showmount client and mountd path are available; otherwise use the task’s given server:/path and verify with findmnt.
- Create the local mountpoint first, fix firewall/SELinux only when needed, and prefer soft/timeo options carefully—exam graders care that the path works and persists.
- EX200 credit is a working, reboot-surviving NFS mount at the required path, not a one-off manual mount that disappears after reboot.
14.1 Mount and Unmount Network File Systems Using NFS
Quick Answer: Mount with
mount -t nfs server:/export /mnt/path, unmount withumount, and persist with an/etc/fstabline of typenfs(often with_netdev). Prove success withfindmnt/df -h. On EX200 you are usually the NFS client—the share already exists on a server named in the task.
Official skill and why it matters
Under Create and configure file systems, Red Hat expects you to mount and unmount network file systems using NFS. Typical lab wording:
- “Mount the NFS share
server1.example.com:/shareat/mnt/nfsdataand ensure it mounts at boot.” - “Configure a persistent NFS mount of
172.25.250.10:/exports/docson/docs.” - “Unmount the NFS file system from
/mnt/tempwhen finished.”
A manual mount that works in your current shell is incomplete if the task requires boot persistence. Pair every durable NFS requirement with a correct fstab (or, in the next section, autofs when the task asks for on-demand mounts).
NFS client vs server (scope control)
| Role | What you configure | EX200 focus for this objective |
|---|---|---|
| Server | nfs-server, exports in /etc/exports, exportfs -r | Often already done by the lab; you may only need client skills |
| Client | Mount, umount, fstab, tools package | Primary skill here |
Do not rebuild an NFS server unless the task explicitly says to export. If you only need to use a share, stay on the client side.
Packages and basic connectivity
On RHEL 10 clients, NFS mount helpers usually ship with the base system or the NFS utilities package. If mount.nfs or showmount is missing:
rpm -q nfs-utils
sudo dnf install -y nfs-utils
Confirm the server is reachable before blaming NFS:
ping -c 2 server1.example.com
# or use the IP the task gives
getent hosts server1.example.com
Name resolution failures produce “cannot resolve” style mount errors—fix DNS/hosts first (networking chapter skills).
Discover exports: showmount (when available)
showmount -e server1.example.com
showmount -e 172.25.250.10
showmount -a server1.example.com # all client mounts (server-side view; if permitted)
showmount -e lists exports advertised by the server (classic NFSv3-style mountd query). Output resembles:
Export list for server1.example.com:
/exports/docs *
/share 172.25.0.0/16
Caveats for the exam:
- Some environments restrict or firewall mountd/rpcbind so
showmounttimes out even though NFSv4 mounting still works on port 2049. - If the task gives you
server:/path, you do not need discovery—use the path as written. - Prefer the exact export string from the task or from a successful
showmountline; trailing path mistakes (/sharevs/shares) fail the mount.
When showmount fails but the task provides the export, proceed with mount -t nfs using that export.
Manual mount: mount -t nfs
Create the local directory first (empty mountpoint):
sudo mkdir -p /mnt/nfsdata
sudo mkdir -p /docs
Mount forms:
# Explicit type (recommended teaching form)
sudo mount -t nfs server1.example.com:/share /mnt/nfsdata
# IP and export path
sudo mount -t nfs 172.25.250.10:/exports/docs /docs
# Often equivalent helpers
sudo mount -t nfs4 server1.example.com:/share /mnt/nfsdata
sudo mount.nfs server1.example.com:/share /mnt/nfsdata
On modern RHEL, nfs frequently negotiates NFSv4 by default. Use nfs4 when a task or troubleshooting requires forcing v4 syntax; otherwise nfs is the standard fstab/mount type you will see in materials.
Useful mount options (client)
| Option | Meaning |
|---|---|
rw / ro | Read-write or read-only |
defaults | Standard local-style defaults bundle |
_netdev | Wait for network (important in fstab) |
vers=4.2 / vers=3 | Force NFS version when required |
soft | Return errors on timeout (can cause app errors) |
hard | Retry indefinitely (default hard behavior is common) |
timeo= / retrans= | Tune timeouts |
bg | Background mount retries (fstab-friendly for boot) |
Example with options:
sudo mount -t nfs -o rw,soft,timeo=30 server1.example.com:/share /mnt/nfsdata
Unless the task specifies options, start with simple defaults or no extra options, then add _netdev for persistence.
Verify the live mount
findmnt /mnt/nfsdata
findmnt -t nfs,nfs4
mount | grep nfs
df -h /mnt/nfsdata
ls /mnt/nfsdata
# Write test only if the task implies a writable share and policy allows:
touch /mnt/nfsdata/exam-test && rm -f /mnt/nfsdata/exam-test
findmnt is the cleanest proof: source should look like server:/export and FSTYPE nfs or nfs4.
Unmount NFS
cd / # never stay inside the mountpoint
sudo umount /mnt/nfsdata
sudo umount -l /mnt/nfsdata # lazy unmount if busy (last resort)
Busy mount errors mean a shell, process, or open file is still using the path:
lsof +f -- /mnt/nfsdata
fuser -vm /mnt/nfsdata
Close those processes or cd out of the directory, then umount again. Do not reboot solely to unmount unless you are out of time and the task requires a clean unmount state.
Persistent NFS: /etc/fstab
Six fields, same as local mounts:
# <file system> <mount point> <type> <options> <dump> <pass>
server1.example.com:/share /mnt/nfsdata nfs defaults,_netdev 0 0
172.25.250.10:/exports/docs /docs nfs defaults,_netdev 0 0
| Field | NFS guidance |
|---|---|
| 1 device | server:/export (not UUID—NFS has no local FS UUID in the same sense) |
| 2 mountpoint | Absolute path; directory must exist |
| 3 type | nfs or nfs4 |
| 4 options | Include _netdev so boot waits for networking |
| 5 dump | 0 |
| 6 pass | 0 (do not fsck remote NFS like local ext4) |
Why _netdev matters
Without _netdev (or equivalent network-aware unit dependency), systemd may try to mount NFS before the network is ready, causing boot delays or failed mounts. RHEL/systemd also understands x-systemd.automount and other advanced options, but for classic EX200-style tasks, defaults,_netdev is the reliable teaching default.
Apply and test fstab
sudo mkdir -p /mnt/nfsdata
# edit /etc/fstab, then:
sudo mount -a
# or mount only that line:
sudo mount /mnt/nfsdata
findmnt /mnt/nfsdata
echo $?
mount -a mounts all non-noauto fstab entries that are not yet mounted. A non-zero exit and an error about NFS usually means wrong server path, firewall, or network.
Optional: use noauto only when the task wants a fstab entry you mount manually later—rare for “mount at boot” wording.
server1.example.com:/share /mnt/nfsdata nfs noauto,_netdev 0 0
End-to-end exam workflows
Workflow A — Persistent NFS mount at boot
Task: Mount utility.lab.example.com:/rhel/shared at /mnt/shared permanently.
rpm -q nfs-utils || sudo dnf install -y nfs-utils
# Optional discovery:
showmount -e utility.lab.example.com
sudo mkdir -p /mnt/shared
# Add to /etc/fstab:
# utility.lab.example.com:/rhel/shared /mnt/shared nfs defaults,_netdev 0 0
sudo mount -a
findmnt /mnt/shared
ls /mnt/shared
Workflow B — Temporary mount only
Task: Mount the share for this session; no mention of boot.
sudo mkdir -p /mnt/temp
sudo mount -t nfs 172.25.250.10:/exports/temp /mnt/temp
findmnt /mnt/temp
# When done:
sudo umount /mnt/temp
Do not leave a broken fstab line if persistence was not requested—but leaving a correct fstab is usually fine if it does not break boot.
Workflow C — showmount unavailable
showmount -e server1
# clnt_create: RPC: Program not registered OR timeout
# Task said: server1.example.com:/public
sudo mkdir -p /public
sudo mount -t nfs server1.example.com:/public /public
findmnt /public
Trust the task’s export path when discovery fails.
Workflow D — Fix a hanging boot mount
If NFS is wrong in fstab, boots can stall. In recovery or after login:
sudo vim /etc/fstab # fix server/export or add noauto/_netdev
sudo mount -a
systemctl --failed
Practice labs: always run mount -a before you rely on reboot.
Firewall and SELinux awareness (client-focused)
- Server must allow NFS (firewalld services
nfs,rpc-bind,mountdfor older styles; NFSv4 often centers on 2049/tcp). If you only control the client and the share is “supposed to work,” focus on client config first. - Client egress is usually open in exam networks; if mount hangs, check routing and that you used the correct server interface/IP.
- SELinux: mounting NFS is generally allowed for standard mountpoints; context issues appear more often when serving NFS or when labeling local content for export. If a service cannot read mounted files, check contexts later without abandoning a correct mount.
NFS vs local mounts (quick comparison)
| Topic | Local disk | NFS |
|---|---|---|
| Identifier in fstab | UUID= / LABEL= | server:/export |
| Type field | xfs, ext4 | nfs / nfs4 |
| pass field | 0–2 | 0 |
| Network dependency | No | Yes (_netdev) |
| Offline behavior | Disk present | Mount fails or hangs if server down |
Common traps
- Forgetting to create the mountpoint —
mkdir -pfirst. - Wrong export path —
/sharevs/exports/share; use task orshowmount -e. - fstab without
_netdev— flaky boot ordering. - pass field 1 or 2 on NFS — keep 0 0.
- Staying in the directory during umount —
cd /thenumount. - Assuming showmount must work — NFSv4-only or firewalled mountd still may allow
mount -t nfs. - Using UUID= for NFS — not the client fstab pattern for remote shares.
- Mount works, fstab missing — fails after reboot; graders check persistence.
- Typo in hostname — verify with
ping/getent hosts. - Confusing this with autofs — static fstab mounts stay mounted; autofs mounts on access (next section).
Relationship to other objectives
| Skill | Where |
|---|---|
| Local UUID/label fstab | Storage mount chapter |
| NFS mount/umount + fstab | This section |
| On-demand automount | Section 14.2 autofs |
| Hostname resolution / firewall | Networking and security chapters |
Section checkpoint
You should install or confirm nfs-utils when needed, discover exports with showmount -e when available, mount with mount -t nfs server:/export /path, unmount safely with umount, write six-field fstab lines using type nfs and options including _netdev with dump/pass 0 0, validate with mount -a and findmnt, and treat reboot survival as the success criterion whenever the task requires a permanent NFS mount. That is the EX200 standard for mounting and unmounting network file systems using NFS.
Which command correctly mounts the NFS export docs from host storage.example.com onto the local directory /mnt/docs?
You must make NFS share server1:/data available at /data after every reboot. Which fstab line best matches common RHEL exam practice?
What does showmount -e nfsserver.example.com typically display for an NFS client?
A shell is still sitting in /mnt/nfsdata and umount /mnt/nfsdata reports the target is busy. What should you do first?