Creating Symbolic Links To create a symbolic link directory /shared pointing to the source directory /data/shared, ensure there's no existing directory named "shared" in the root directory, then execute:
ln -s /data/shared /shared
Verify the link with:
ll shared
# Output: shared -> /data/shared
Note: Configure firewall settings beforehand, or disable it during testing.
Firewall Configuration Check firewall status and control it with:
# Check firewall status
systemctl status firewalld
# Stop firewall
systemctl stop firewalld
# Start firewall
systemctl start firewalld
# Enable at boot
systemctl enable firewalld
# Disable at boot
systemctl disable firewalld
# Stop iptables
systemctl stop iptables
# Permanently disable SELinux
vi /etc/selinux/config
# Change: SELINUX=enforcing to SELINUX=disabled
# Save and exit
Re-mounting with Correct Permissions For NAS re-mounting directory permissions:
mount -o remount, rw /shared/upload
NFS Server Configuration Create and configure shared directories:
# Create directories
mkdir -p /shared/upload
chmod -R 777 /shared/upload
# Install NFS utilities
yum -y install nfs-utils rpcbind
# Start services
systemctl start nfs
systemctl start rpcbind
# Enable at boot
systemctl enable nfs
systemctl enable rpcbind
# Configure firewall rules
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
# Configure shared directories in exports file
vi /etc/exports
# Add these lines:
/shared/upload 10.10.10.98(rw,sync,no_root_squash)
/shared/app 10.10.10.98(rw,sync,no_root_squash)
# For IP range access
/shared/upload 10.10.*.*(rw,no_root_squash,sync)
/data/vhost 10.10.10.0/24(rw,no_root_squash,sync)
# Reload exports
exportfs -rv
# Verify shared directories
showmount -e
NFS Client Configuration Configure NFS client to access the server:
# Create local mount point
mkdir -p /shared/upload
# Install NFS utilities
yum -y install nfs-utils
# Start NFS client service
systemctl start nfs
# Enable at boot
systemctl enable nfs
# Check available shares on server
showmount -e 10.10.10.98
# Mount server directory
mount -t nfs 10.10.10.98:/shared/upload /shared/upload
# Mount with read-only and additional options
mount -t nfs -o ro,hard,intr,proto=tcp 10.10.10.98:/shared/upload /shared/upload
# Mount with specific NFS version and timeout
mount -t nfs -o vers=3,timeo=600,nolock 10.10.10.98:/shared/upload /shared/upload
# Unmount
umount 10.10.10.198:/shared/upload
# Re-mount with read-write permissions
mount -o remount, rw /shared/upload
# Configure automatic mounting at boot
vi /etc/fstab
# Add these lines:
10.10.10.98:/shared/upload /shared/upload nfs4 defaults 0 0
10.10.10.98:/shared/upload /shared/upload nfs vers=3,timeo=600,nolock 0 0
/etc/fstab Configuration The fstab file has six fields:
Device: The partitino device file or UUID Mount Point: Directory where the filesystem is mounted Filesystem Type: Type of filesystem (nfs, ext4, etc.) Options: Mount options matching mount command parameters Dump: Whether the filesystem should be backed up (0=none, 1=backup, 2=periodic) fsck: Whether fielsystem should be checked (0=none, 1=high priority, 2=low priority)
Note: If "df" hangs, it's likely because a mounted directory was deleted without unmounting first.
Solution: Check /etc/fstab for mount entries and remove them, then unmount with:
umount -l 10.176.22.132:/shared/upload
NFS Mount Options
ro: Read-only access (default) rw: Read-write access root_squash: Maps root user to anonymous user (nobody) for security no_root_squash: Gives root full permissions (not recommended for security) no_all_squash: Preserves UID/GID of shared files (default) sync: Commits changes to stable storage
CentOS 8 NFS Service Management
# Restart NFS server
systemctl restart nfs-server
# Enable at boot
systemctl enable nfs-server
exportfs Command Options
# -a: Mount or unmount all shares
# -r: Re-export all directories
# -u: Unmount specific directory
# -v: Display shared directories
fstab Mount Options The "defaults" option includes: rw, suid, dev, exec, auto, nouser, async
async/sync: Asynchronous (faster, less secure) vs synchronous (slower, more secure) auto/noauto: Mount at boot or only when explicitly mounted exec/noexec: Allow or disallow execution of binaries user/nouser: Allow or disallow regular users to mount suid/nosuid: Allow or disallow SUID permissions usrquota/grpquota: Enable disk quota support
Stopping NFS Services
# Check and stop rpcbind services
systemctl status rpcbind.socket
systemctl stop rpcbind.socket
systemctl disable rpcbind.socket
systemctl status rpcbind
systemctl stop rpcbind
systemctl disable rpcbind
# Check and stop NFS service
systemctl status nfs
systemctl stop nfs
systemctl disable nfs
# For CentOS 8
systemctl status nfs-server
systemctl stop nfs-server
systemctl disable nfs-server