Managing Network Storage
Theory Questions
1. List shares offered by an NFS server.
- Command(s):
showmount -e server2
- Why:
showmount -equeries the remote RPC mount daemon (rpc.mountd) on the specified NFS host and retrieves its export list. - Gotchas:
showmount -erelies on RPC port 20048 (mountd) and port 111 (rpcbind). If the server strictly enforces NFSv4 without legacy RPC support or has port filters active,showmountmay fail even if NFSv4 shares are accessible. - Verify:
showmount -e server2
2. Identify features that are and are not part of NFSv4.
- Command(s):
rpcinfo -p server2
mount | grep nfs4
-
Why:
-
Part of NFSv4: Single TCP port operation (port 2049), integrated locking and mount protocols (no auxiliary
lockd/mountddaemons), pseudo-filesystem export hierarchy, strong security options (Kerberos/RPCSEC_GSS), and stateful protocol operations. -
NOT Part of NFSv4: UDP transport support (NFSv4 is strictly TCP), reliance on
rpcbind(port 111), auxiliary RPC daemons (statd,lockd,mountd). -
Gotchas: Attempting to configure legacy RPC ports or specifying
udpin NFSv4 mount options will cause connection errors. -
Verify:
nfsstat -c
3. Identify the package required to mount NFS shares on a client.
- Command(s):
dnf install -y nfs-utils
- Why: The
nfs-utilspackage provides essential client-side helper utilities including/sbin/mount.nfs,showmount,nfsidmap, and key-management daemons required to handle NFS filesystems. - Gotchas: Attempting
mount -t nfs ...on a minimal installation without installingnfs-utilsyieldsmount: wrong fs type, bad option, bad superblock...errors. - Verify:
rpm -q nfs-utils
4. Diagnose why showmount -e returns no results.
- Command(s):
# Check daemon status on server:
systemctl status nfs-server
# Check server firewall rules:
firewall-cmd --list-services
# Test RPC connectivity from client:
rpcinfo -p <server-ip>
- Why:
showmount -efails when:
nfs-serverdaemon is stopped or uninitialized.- Firewall blocks RPC services (
rpc-bind,mountd, or port 20048/111). - No exports are defined in
/etc/exportsor/etc/exports.d/*.exports. - The NFS server uses pure NFSv4 without running
rpc.mountd.
- Gotchas: Assuming
showmountfailure means NFS mounting is impossible; NFSv4 pseudo-root shares can often still be mounted directly even ifshowmountis blocked. - Verify:
mount -t nfs4 server2:/ /mnt
5. Identify the systemd service that provides NFS shares.
- Command(s):
systemctl status nfs-server
- Why:
nfs-server.servicemanages kernel NFS server daemons (nfsd), exports tables, and coordination daemons on Enterprise Linux. - Gotchas: Confusing
nfs-server.servicewithnfs-client.targetornfs-mountd.service. On the server side,nfs-serveris the main service unit to enable. - Verify:
systemctl is-active nfs-server
6. Use the correct mount option in /etc/fstab for NFS shares.
- Command(s) / Entry:
server2:/shares/data /mnt/data nfs defaults,_netdev,nfsvers=4 0 0
- Why: The
_netdevoption instructs systemd to delay mounting the filesystem until network interfaces and network management services are active. - Gotchas: Omitting
_netdev. If_netdevis missing, systemd attempts early boot mounting before network interfaces are online, causing system boot delays or drops into emergency mode. - Verify:
findmnt --verify
mount -a
7. Identify required and non-required steps in configuring automount.
- Command(s):
dnf install -y autofs
systemctl enable --now autofs
-
Why:
-
Required Steps: Install
autofs, configure master map (/etc/auto.masteror/etc/auto.master.d/*.autofs), configure map files (/etc/auto.home), enable and startautofs.service. -
Non-required Steps: Creating local target mount directories manually, editing
/etc/fstab, pre-mounting NFS shares manually viamount. -
Gotchas: Pre-creating target subdirectories inside an indirect automount directory.
autofscreates and removes indirect subdirectories dynamically on demand. -
Verify:
systemctl is-active autofs
8. Name the automount configuration file for a given directory.
- Path / Command:
Master Map Drop-in:
/etc/auto.master.d/<name>.autofsIndirect Map File:/etc/auto.<name>(e.g.,/etc/auto.home) - Why: System drop-in files under
/etc/auto.master.d/*.autofskeep custom modular configurations clean and separate from global/etc/auto.masterdefaults. - Gotchas: Omitting the required
.autofsextension on drop-in configuration files inside/etc/auto.master.d/. - Verify:
cat /etc/auto.master.d/home.autofs
9. Write a wildcard automount configuration line using NFS.
- Command(s) / Entry:
Inside map file (e.g.,
/etc/auto.home):
* -rw,sync,nfsvers=4 server2:/home/&
- Why:
*acts as a wildcard key matching any requested path access under the automount directory;&dynamically substitutes the matched key into the remote export path. - Gotchas: Hardcoding explicit usernames in the remote path field instead of using the ampersand
&variable. - Verify:
cat /etc/auto.home
10. Identify the service that implements automount.
- Command(s):
systemctl status autofs
- Why:
autofs.servicemanages the kernel automounter subsystem, reading map definitions and generating dynamic on-demand mount triggers upon directory access. - Gotchas: Service name is
autofs, notautomount. - Verify:
systemctl is-enabled autofs
11. Show available NFS mounts on a specific server.
- Command(s):
showmount -e server2
- Why: Sends RPC queries to
server2to display exported filesystems and allowed client subnet ACLs. - Gotchas: Hostname resolution failures; ensure
server2is resolvable via/etc/hostsor DNS. - Verify:
showmount -e server2
12. Mount an NFS share from a specific server.
- Command(s):
mkdir -p /mnt/data
mount -t nfs -o nfsvers=4 server2:/shares/data /mnt/data
- Why: Mounts remote exported filesystem
server2:/shares/datadirectly to local directory/mnt/data. - Gotchas: Forgetting to create local target mount directory prior to running explicit
mountcommands. - Verify:
findmnt /mnt/data
13. Mount all NFS shares from a server to a local directory.
- Command(s):
mkdir -p /mnt/nfs-root
mount -t nfs4 server2:/ /mnt/nfs-root
- Why: NFSv4 exports an overarching pseudo-root filesystem (
/). Mountingserver2:/mounts the top-level tree, exposing all underlying exported shares as subdirectories. - Gotchas: Attempting pseudo-root mounts on legacy NFSv3 servers (NFSv3 requires individual share mounts).
- Verify:
ls -l /mnt/nfs-root
14. Ensure NFS shares mount only after network services have started.
- Command(s) / Entry:
In
/etc/fstab:
server2:/shares/data /mnt/data nfs defaults,_netdev 0 0
- Why: The
_netdevmount flag forces systemd to insert explicit dependencies (Wants=network-online.target,After=network-online.target) into generated mount units. - Gotchas: Missing
_netdevcan cause boot failure or severe hangs during early system startup phases. - Verify:
systemctl show mnt-data.mount | grep -i "After"
15. Ensure changes to a mounted file system are written to the NFS server immediately.
- Command(s) / Entry:
In
/etc/fstabor server export parameters:
server2:/shares/data /mnt/data nfs defaults,_netdev,sync 0 0
- Why:
syncforces synchronous I/O operations, ensuring data writes are committed to physical server storage before confirming execution back to calling applications. - Gotchas: Using
asyncimproves write performance by buffering in memory, but risks data loss during ungraceful server power cuts;syncprioritizes consistency. - Verify:
mount | grep "sync"
16. Identify autofs features not supported by systemd automount.
- Key Features:
- Wildcard mapping (
*key matching and&path substitution). - Executable map scripts (dynamic programmatic map generation).
- Master map syntax parsing (
/etc/auto.master). - LDAP and NIS directory server map integrations.
- Why: Systemd
.automountunits handle static individual mount targets, whereasautofsprovides dynamic pattern matching for variable targets (such as dynamic user home directories). - Gotchas: Attempting to build wildcard dynamic home directory mounts using static systemd
.automountfiles. - Verify:
man autofs
17. Identify the main automount configuration file.
- Path / Command:
/etc/auto.master
- Why: Main configuration entry point for
autofs, controlling top-level base directories, mapping files, and lookup source pointers. - Gotchas: Adding dynamic user mapping lines straight into
/etc/auto.masterinstead of delegating to secondary map files like/etc/auto.home. - Verify:
cat /etc/auto.master
18. Identify the automount service name.
- Command:
systemctl status autofs
- Why:
autofs.servicemanages automount daemon processes. - Gotchas: Confusing
autofsservice name withautomount. - Verify:
systemctl is-active autofs
19. Determine which firewall ports the automount client needs open.
- Command(s):
# NFSv4 requires outbound TCP port 2049 on the client.
# If configuring server side firewalld:
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
- Why: NFSv4 operates across TCP port
2049. Clients initiate outbound connections to server port 2049. - Gotchas: Opening client inbound ports unnecessarily when standard client automount requires only outbound access to server port 2049.
- Verify:
nc -zv server2 2049
Lab Tasks
Network Storage Practice
Task 1: Set up an NFS server that shares the /home directory on server2.
- Command(s):
# Execute on server2:
# 1. Install NFS server utilities
dnf install -y nfs-utils
# 2. Configure export for /home
echo "/home *(rw,sync,no_root_squash)" > /etc/exports.d/home.exports
# 3. Start and enable nfs-server
systemctl enable --now nfs-server
# 4. Export the configured shares
exportfs -r
# 5. Configure firewalld rules
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
-
Why:
-
echo "/home ...": Shares/homedirectory with read-write (rw) privileges and synchronous disk operations (sync). -
exportfs -r: Refreshes export table without restarting the NFS service. -
firewall-cmd: Opens necessary firewall ports for client communication. -
Gotchas:
-
Forgetting to run
exportfs -rafter creating files in/etc/exports.d/. -
Omitting
no_root_squashif remote root administrative write access is required for home directory setup. -
Forgetting to make firewall rules
--permanent. -
Verify:
# Verify export table on server2:
exportfs -v
# Check NFS server service state:
systemctl is-active nfs-server
(Ensure persistent service execution across reboots via systemctl is-enabled nfs-server)
Task 2: Configure server1 to access the NFS-shared home directory using automount with wildcard automount configuration.
- Command(s):
# Execute on server1:
# 1. Install autofs and nfs-utils
dnf install -y autofs nfs-utils
# 2. Create master map drop-in configuration
echo "/home /etc/auto.home" > /etc/auto.master.d/home.autofs
# 3. Create indirect wildcard mapping file
echo "* -rw,sync,nfsvers=4 server2:/home/&" > /etc/auto.home
# 4. Enable and start autofs service
systemctl enable --now autofs
-
Why:
-
/etc/auto.master.d/home.autofs: Maps accesses to/hometo rules defined in/etc/auto.home. -
* -rw,sync,nfsvers=4 server2:/home/&: Dynamic wildcard configuration where any user access attempt to/home/<username>triggers an on-demand NFSv4 mount ofserver2:/home/<username>. -
systemctl enable --now autofs: Activates automounter service immediately and persists it across system reboots. -
Gotchas:
-
Pre-creating user subdirectories inside
/homeonserver1.autofshandles directory creation in memory dynamically; pre-existing physical directories block automount operations. -
Forgetting the
.autofsextension on/etc/auto.master.d/home.autofs. -
Typing
&incorrectly or forgetting the-before option strings (-rw,sync). -
Verify:
# 1. Verify autofs service status:
systemctl status autofs
# 2. Test dynamic automounting (assuming user1 exists on server2:/home/user1):
cd /home/user1
df -hT /home/user1
(Output should show server2:/home/user1 mounted on /home/user1 with type nfs4)
- Reboot Persistence Verification:
reboot
# Post-reboot check:
cd /home/user1
findmnt /home/user1
(Confirms autofs initializes on boot and mounts user home directories dynamically upon access)