Network File System (NFS)
NFS Basics and Configuration
Same tools for mounting and unmounting a filesystem.
- Mounted and accessed the same way as local filesystems.
- Network protocol that allows file sharing over the network.
- Multi-platform
- Multiple clients can access a single share at the same time.
- Reduced overhead and storage cost.
- Give users access to uniform data.
- Consolidate scattered user home directories.
- May cause client to hang if share is not accessible.
- Share stays mounted until manually unmounted or the client shuts down.
- Does not support wildcard characters or environment variables.
NFS Supported versions
- RHEL 9 Supports versions 3,4.0,4.1, and 4.2 (default)
- NFSv3 supports:
- TCP and UDP.
- asynchronous writes.
- 64-bit files sizes.
- Access files larger than 2GB.
- NFSv4.x supports:
- All features of NFSv3.
- Transit firewalls and work on internet.
- Enhanced security and support for encrypted transfers and ACLs.
- Better scalability
- Better cross-platform
- Better system crash handling
- Use usernames and group names rather than UID and GID.
- Uses TCP by default.
- Can use UDP for backwards compatibility.
- Version 4.2 only supports TCP
Network File System service
- Export shares to mount on remote clients
- Exporting
- When the NFS server makes shares available.
- Mounting
- When a client mounts an exported share locally.
- Mount point should be empty before trying to mount a share on it.
- System can be both client and server.
- Entire directory tree of the share is shared.
- Cannot re-share a subdirectory of a share.
- A mounted share cannot be exported from the client.
- A single exported share is mounted on a directory mount point.
- Make sure to update the fstab file on the client.
NFS Server and Client Configuration
How to export a share
- Add entry of the share to /etc/exports using
exportfscommand - Add firewall rule to allow access
Mount a share from the client side
- Use
mountand add the filesystem to the fstab file.
Lab: Export Share on NFS Server
- Install nfs-utils
- Create /common
- Add full permissions
- Add NFS service persistently to the firewalld configuration to allow NFS traffic and load the new rule:
- Start the NFS service and enable it to autostart at system reboots:
- Verify Operational Status of the NFS services:
- Open /etc/exports and add entry for /common to export it to server10 with read/write:
- Export the entry defined in /etc/exports/. -a option exports all entries in the file. -v is verbose.
- Unexport the share (-u):
- Re-export the share:
LAB: Mount share on NFS client
- Install nfs-utils
- Create /local mount point
- Mount the share manually:
- Confirm using mount: (shows nfs version)
- Confirm using df:
- Add to /fstab for persistence:
Note:
- Unmount share manually using umount then remount to validate accuracy of the entry in /fstab:
- Verify:
- Create a file in /local/ and verify:
- Confirm the sync on server 2
- Update fstab