6. Create and Configure File Systems
πRed Hat Certified System Administrator (RHCSA β EX200)
What is NFS?
- NFS (Network File System) is a protocol that allows a computer (client) to access files over a network as if they were on its local hard drive.
- Example: A developer on one server can read/write files that are physically stored on a different server, without copying them.
- NFS is mostly used in Linux and Unix environments.
Why NFS is Important in IT
- Shared storage for multiple servers (e.g., web servers accessing the same configuration files).
- Centralized data management (all backups happen from one location).
- Easy collaboration between systems in a network.
How NFS Works
- Server: The machine that shares directories.
- Client: The machine that mounts and uses the shared directories.
- Exports: The directories on the server that are available to clients.
- Mounting: Connecting the client to the NFS server to use the shared folder.
Think of mounting like βconnecting to a shared driveβ on another server.
Step 1: Install NFS Tools
- On Linux, you need NFS packages installed:
# On the server (Red Hat/CentOS/Fedora)
sudo yum install nfs-utils -y# On the client
sudo yum install nfs-utils -y
Step 2: Configure the NFS Server
- Create a directory to share:
sudo mkdir -p /srv/nfs/shared
- Give proper permissions:
sudo chown nobody:nogroup /srv/nfs/shared
sudo chmod 777 /srv/nfs/shared
- Edit
/etc/exportsfile to define which clients can access the directory:
/srv/nfs/shared 192.168.1.10(rw,sync,no_root_squash)
192.168.1.10β IP of the client allowed to connect.rwβ read and write permission.syncβ changes are written immediately.no_root_squashβ allows root on client to have root permissions on the shared folder.
- Start and enable NFS server services:
sudo systemctl enable nfs-server
sudo systemctl start nfs-server
- Export the directories:
sudo exportfs -a
- Check shared directories:
sudo exportfs -v
Step 3: Mount NFS on the Client
- Create a mount point:
sudo mkdir -p /mnt/nfs/shared
- Mount the NFS share:
sudo mount 192.168.1.20:/srv/nfs/shared /mnt/nfs/shared
192.168.1.20β NFS server IP./mnt/nfs/sharedβ local mount point on the client.
- Verify mount:
mount | grep nfs
or
df -h
Step 4: Make NFS Mount Persistent (Optional but Exam-Relevant)
- Edit
/etc/fstabto mount NFS automatically at boot:
192.168.1.20:/srv/nfs/shared /mnt/nfs/shared nfs defaults 0 0
Step 5: Unmount NFS
- To safely unmount:
sudo umount /mnt/nfs/shared
- Always unmount before shutting down or disconnecting the network share to avoid data corruption.
Step 6: Common NFS Commands
| Command | Purpose |
|---|---|
showmount -e <server> | Show exported directories from server |
mount -t nfs <server>:/path /mountpoint | Mount NFS manually |
umount /mountpoint | Unmount NFS |
exportfs -v | List exported directories on server |
Key Points for Exam
- Server vs Client roles: Know which commands go where.
- NFS Permissions:
rw,ro,sync,no_root_squashare important. - Mounting/unmounting: You must know
mount,umount, and/etc/fstab. - Network accessibility: NFS requires network connectivity; the client must reach the server.
- Verification: Always check
mount,df -h, orshowmount -e.
Real-Life IT Examples
- Multiple Linux web servers reading from the same content directory on a central server.
- Backup servers accessing critical data directories over the network.
- A development team accessing a shared code repository folder hosted on another server.
β Summary
- NFS allows network-wide file sharing.
- Configure server exports, mount client directories, and unmount safely.
/etc/exportsand/etc/fstabare key files to remember.- Use NFS commands to verify and troubleshoot.
