Red Hat System Administration II · RH134

Chapter 15

Accessing Network-Attached Storage

NFS · fstab · autofs · Samba/CIFS · Troubleshooting
CIS238RH — Mesa Community College
Mount NFS and Samba/CIFS shares manually and persistently, and configure autofs for on-demand mounting.

Key Commands

  • showmount
  • mount -t nfs
  • autofs
  • mount -t cifs
ProtocolPrimary Use Case
NFS (Network File System)The standard for sharing storage between Linux/Unix systems
SMB/CIFS (Samba)Interoperating with Windows file shares, or Linux systems serving Windows clients
Why It MattersNetwork storage adds failure modes local disks don't have: an unreachable server, server-side permissions, and network path problems.
# Discover what an NFS server is exporting, before mounting anything
showmount -e nfsserver.example.com

# Create a mount point
sudo mkdir -p /mnt/nfsdata

# Mount an NFS export
sudo mount -t nfs nfsserver.example.com:/exports/data /mnt/nfsdata

# Confirm it mounted
df -h /mnt/nfsdata

# Unmount when done
sudo umount /mnt/nfsdata
Noteshowmount queries the older mountd service. An NFSv4-only server may not answer it, even though mounting still works.
# /etc/fstab entry for an NFS mount
nfsserver.example.com:/exports/data  /mnt/nfsdata  nfs  defaults  0  0

# Test it without rebooting, same as any fstab entry (Chapter 10)
sudo mount -a
Warning — Boot RiskIf the server is unreachable at boot, an NFS fstab entry can delay or hang startup. Consider options like _netdev, nofail, and timeouts.

autofs mounts a share when it's first accessed and unmounts it after a period of inactivity, avoiding the boot-time risk of a static fstab entry.

# Install autofs if not already present
sudo dnf install autofs

# /etc/auto.master — maps a mount point prefix to a map file
/mnt/auto  /etc/auto.mnt
TipOn RHEL, you can instead put that master-map line in its own file, such as /etc/auto.master.d/mnt.autofs.
# /etc/auto.mnt — the actual map, defining what mounts where
# key       options                    location
data        -fstype=nfs,rw             nfsserver.example.com:/exports/data

# Enable and start the service
sudo systemctl enable --now autofs

# Accessing this path triggers the mount automatically
ls /mnt/auto/data
NoteNo manual mount is needed. autofs creates /mnt/auto/data on access.
# Install the CIFS mount utilities if needed
sudo dnf install cifs-utils

# Mount a Windows/Samba share, prompting for a password
sudo mount -t cifs //fileserver.example.com/shared /mnt/winshare -o username=student

# Store credentials in a protected file instead of typing them each time
sudo mount -t cifs //fileserver.example.com/shared /mnt/winshare -o credentials=/etc/samba/creds
# /etc/fstab entry using a credentials file
//fileserver.example.com/shared  /mnt/winshare  cifs  credentials=/etc/samba/creds  0  0

# /etc/samba/creds contains:
username=student
password=secret

# Lock it down
sudo chmod 600 /etc/samba/creds
WarningThe credentials file holds a plaintext password. Make it readable only by root.
# Confirm basic network reachability to the server
ping nfsserver.example.com

# Confirm the export is actually visible
showmount -e nfsserver.example.com

# Check what's currently mounted, and how
mount | grep nfs

# Check recent kernel/service messages related to the mount
journalctl -xe | grep -i nfs
SymptomLikely Cause
Mount hangs indefinitelyServer unreachable, or firewall blocking the required ports
"Permission denied" after mountingServer-side export permissions or client UID/GID mismatch
Mount succeeds but disappears laterautofs idle timeout (expected) vs. an unexpected disconnect (not expected)
NFS
Network File System, the standard Linux/Unix network file sharing protocol
export
A directory an NFS server makes available to clients
showmount
Lists the exports an NFS server is offering
autofs
Mounts shares on access and unmounts them when idle
SMB/CIFS
The Windows file sharing protocol, implemented on Linux by Samba
credentials file
A root-only file holding the username and password for a CIFS mount
  1. What command lets you check what an NFS server is exporting before attempting to mount anything?
  2. Why can a permanent /etc/fstab entry for an NFS share be risky at boot time if the server is unreachable?
  3. What problem does autofs solve compared to a static fstab entry for a network share?
  4. Why should a CIFS credentials file have restricted permissions?
  5. A network share mount hangs indefinitely with no error. What's the most likely category of problem?
  6. A share mounts successfully, but every file access returns "permission denied." What's the most likely category of problem?
  7. Write a command that mounts //fileserver.example.com/shared on /mnt/winshare using the credentials file /etc/samba/creds.