argocd
numpy
scheme
+
+
pinecone
!
raspbian
webstorm
+
lua
โˆ‰
tf
+
erlang
+
+
+
+
+
+
ractive
+
laravel
โˆ‚
dns
cypress
+
aurelia
$
+
+
cargo
+
css
+
sublime
spacy
+
helm
influxdb
cdn
numpy
+
+
cypress
+
mint
aws
elementary
redhat
+
http
+
emacs
alpine
+
micronaut
dask
+
+
+
c#
+
+
+
lua
+
smtp
https
+
netlify
+
+=
nomad
+
#
+
koa
+
+
+
echo
+
+
==
+
+
Back to Blog
๐ŸŒ Setting Up NFS Network File System on AlmaLinux: Share Files Across Your Network Like Magic
AlmaLinux NFS Network File System

๐ŸŒ Setting Up NFS Network File System on AlmaLinux: Share Files Across Your Network Like Magic

Published Aug 29, 2025

Master NFS configuration on AlmaLinux with this beginner-friendly guide. Learn to set up network file sharing, configure exports, manage permissions, and optimize performance for seamless file access across your network!

5 min read
0 views
Table of Contents

๐ŸŒ Setting Up NFS Network File System on AlmaLinux: Share Files Across Your Network Like Magic

Hey there, network storage wizard! ๐Ÿง™โ€โ™‚๏ธ Ever wished you could access your files from any computer on your network as if they were stored locally? You know that frustration when you need a file from another machine and have to deal with USB drives or slow file transfers? Well, Iโ€™ve got something amazing for you - NFS (Network File System)!

I remember when I first discovered NFSโ€ฆ it was like finding a secret door between all my computers! ๐Ÿšช Suddenly, I could edit files on my workstation that were actually stored on my server, and everything just worked seamlessly. By the end of this guide, youโ€™ll have your own NFS setup running, and trust me, youโ€™ll wonder how you ever lived without it!

๐Ÿค” Why is NFS Important?

NFS is like having a magical portal for your files! ๐ŸŒŸ Let me share why this is such a game-changer:

The Power of NFS:

  • ๐Ÿš€ Lightning-Fast Access - Much faster than SMB/CIFS for Linux systems
  • ๐Ÿ”„ Real-Time Sync - Changes appear instantly across all connected systems
  • ๐Ÿ’ป Native Linux Integration - Works seamlessly with Linux permissions
  • ๐ŸŽฏ Transparent Access - Remote files appear as local files to applications
  • ๐Ÿ“Š Centralized Storage - Keep all data in one secure location
  • ๐Ÿ” Granular Security - Control access down to individual directories
  • โšก Low Overhead - Minimal CPU and memory usage
  • ๐ŸŒ Cross-Platform - Works with Unix, Linux, and even Windows (with tools)

๐ŸŽฏ What You Need

Before we dive into the NFS magic, letโ€™s check our toolkit! ๐Ÿ› ๏ธ Hereโ€™s what youโ€™ll need:

Prerequisites:

  • โœ… AlmaLinux 8 or 9 installed (server and client machines)
  • โœ… Root or sudo access on both systems
  • โœ… Network connectivity between machines
  • โœ… Basic understanding of IP addresses
  • โœ… At least 1GB free disk space for shared directories
  • โœ… Firewall access (weโ€™ll configure it!)
  • โœ… About 45 minutes of your time
  • โœ… Excitement to master network storage! ๐ŸŽ‰

๐Ÿ“ Step 1: Installing NFS Server Components

Letโ€™s start by setting up the NFS server! ๐ŸŽฏ This is the machine that will share its files.

Install NFS Packages:

# Update system packages first - always start fresh!
sudo dnf update -y

# Install NFS server packages
sudo dnf install nfs-utils -y

# Install additional helpful tools
sudo dnf install rpcbind -y

# Check installed version
rpm -qa | grep nfs-utils
# Output: nfs-utils-2.5.x - Perfect! โœ…

# Enable NFS server services
sudo systemctl enable --now nfs-server rpcbind

# Start the services if not already running
sudo systemctl start nfs-server rpcbind

# Verify services are active
sudo systemctl status nfs-server
# Output: Active (running) - Excellent! ๐ŸŽ‰

Configure Firewall for NFS:

# Add NFS service to firewall
sudo firewall-cmd --permanent --add-service=nfs

# Add RPC bind service
sudo firewall-cmd --permanent --add-service=rpc-bind

# Add mountd service
sudo firewall-cmd --permanent --add-service=mountd

# Reload firewall to apply changes
sudo firewall-cmd --reload

# List allowed services
sudo firewall-cmd --list-services
# Should show: nfs rpc-bind mountd (among others)

# For NFSv4, also open port 2049
sudo firewall-cmd --permanent --add-port=2049/tcp
sudo firewall-cmd --reload

๐Ÿ”ง Step 2: Creating and Configuring Shared Directories

Time to create the directories weโ€™ll share! ๐Ÿ“ Think of these as your network treasure chests.

Create Share Directories:

# Create main NFS share directory
sudo mkdir -p /nfs/shared

# Create department-specific shares (examples)
sudo mkdir -p /nfs/public
sudo mkdir -p /nfs/documents
sudo mkdir -p /nfs/backups
sudo mkdir -p /nfs/media

# Set initial permissions
sudo chmod 755 /nfs/shared
sudo chmod 777 /nfs/public  # Public access
sudo chmod 750 /nfs/documents  # Restricted access

# Create some test files
echo "Welcome to NFS! ๐ŸŽ‰" | sudo tee /nfs/shared/welcome.txt
echo "This is publicly accessible" | sudo tee /nfs/public/readme.txt

# Check directory structure
tree /nfs/
# Shows your NFS directory hierarchy

Set Proper Ownership:

# Create NFS user for better security (optional)
sudo useradd -r -s /sbin/nologin nfsuser

# Set ownership for shared directories
sudo chown -R nfsuser:nfsuser /nfs/shared
sudo chown -R nobody:nobody /nfs/public

# For user-specific shares
sudo chown -R $(whoami):$(whoami) /nfs/documents

# Verify ownership
ls -la /nfs/
# Shows ownership details

๐ŸŒŸ Step 3: Configuring NFS Exports

Now for the magic configuration! โœจ This tells NFS what to share and how.

Edit NFS Exports File:

# Backup original exports file
sudo cp /etc/exports /etc/exports.backup

# Edit the exports configuration
sudo nano /etc/exports

Add these export configurations (Iโ€™ll explain each option!):

# Public share - accessible by everyone on the network
/nfs/public     192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)

# Shared directory - read-write for specific network
/nfs/shared     192.168.1.0/24(rw,sync,root_squash,no_subtree_check)

# Documents - read-only for most, read-write for specific host
/nfs/documents  192.168.1.0/24(ro,sync,root_squash,no_subtree_check)
/nfs/documents  192.168.1.100(rw,sync,no_root_squash,no_subtree_check)

# Media share - optimized for large files
/nfs/media      *(ro,sync,no_root_squash,no_subtree_check,async)

# Backup share - specific host only
/nfs/backups    192.168.1.50(rw,sync,no_root_squash,no_subtree_check)

What these options mean: ๐Ÿ“–

  • rw = Read-write access
  • ro = Read-only access
  • sync = Write operations are committed to disk immediately
  • async = Write operations are buffered (faster but less safe)
  • no_root_squash = Root on client has root access on server
  • root_squash = Root on client is mapped to nobody user (safer)
  • no_subtree_check = Improves performance

Apply Export Configuration:

# Export the shared directories
sudo exportfs -arv

# Output shows exported directories:
# exporting 192.168.1.0/24:/nfs/public
# exporting 192.168.1.0/24:/nfs/shared
# ... and so on

# Verify exports
sudo exportfs -v
# Shows all current exports with options

# Check NFS shares from the server itself
showmount -e localhost
# Lists all available exports

โœ… Step 4: Setting Up NFS Client

Letโ€™s configure client machines to access our NFS shares! ๐Ÿ–ฅ๏ธ This is where the magic becomes real.

Install NFS Client Tools:

# On the client machine, install NFS utilities
sudo dnf install nfs-utils -y

# Install additional tools
sudo dnf install nfs4-acl-tools -y

# Enable and start required services
sudo systemctl enable --now rpcbind

# Check if server is reachable
ping -c 3 NFS_SERVER_IP
# Replace NFS_SERVER_IP with your server's IP

Mount NFS Shares:

# Create mount points on client
sudo mkdir -p /mnt/nfs/shared
sudo mkdir -p /mnt/nfs/public
sudo mkdir -p /mnt/nfs/documents

# Show available exports from server
showmount -e 192.168.1.10  # Replace with your server IP
# Lists all available shares

# Mount the shares manually
sudo mount -t nfs 192.168.1.10:/nfs/shared /mnt/nfs/shared
sudo mount -t nfs 192.168.1.10:/nfs/public /mnt/nfs/public

# Verify mounts
df -h | grep nfs
# Shows mounted NFS filesystems

# Test access
ls -la /mnt/nfs/shared/
cat /mnt/nfs/shared/welcome.txt
# Output: Welcome to NFS! ๐ŸŽ‰

Configure Automatic Mounting:

# Edit fstab for persistent mounts
sudo nano /etc/fstab

# Add these lines (adjust IP and paths):
192.168.1.10:/nfs/shared    /mnt/nfs/shared    nfs    defaults,_netdev    0 0
192.168.1.10:/nfs/public    /mnt/nfs/public    nfs    defaults,_netdev    0 0
192.168.1.10:/nfs/documents  /mnt/nfs/documents nfs    defaults,_netdev,ro 0 0

# Mount all fstab entries
sudo mount -a

# Verify all mounts
mount | grep nfs

๐ŸŽฎ Quick Examples

Letโ€™s see NFS in action with real-world scenarios! ๐Ÿš€

Example 1: Shared Project Directory

# On NFS Server - Create project share
sudo mkdir -p /nfs/projects/web-app
sudo chmod 775 /nfs/projects/web-app

# Add to /etc/exports
echo "/nfs/projects 192.168.1.0/24(rw,sync,no_root_squash)" | sudo tee -a /etc/exports

# Apply changes
sudo exportfs -arv

# On Client - Mount and use
sudo mkdir -p /mnt/projects
sudo mount -t nfs 192.168.1.10:/nfs/projects /mnt/projects

# Now multiple developers can work on same project!
cd /mnt/projects/web-app
echo "<?php echo 'Hello from NFS!'; ?>" > index.php

# Changes appear instantly on all clients! ๐ŸŽ‰

Example 2: Central Media Server

# On NFS Server - Set up media share
sudo mkdir -p /nfs/media/{movies,music,photos}
sudo chmod 755 /nfs/media

# Copy some media files
sudo cp -r ~/Videos/* /nfs/media/movies/ 2>/dev/null
sudo cp -r ~/Music/* /nfs/media/music/ 2>/dev/null

# Configure read-only export for media
echo "/nfs/media *(ro,sync,no_subtree_check,async)" | sudo tee -a /etc/exports
sudo exportfs -arv

# On Client - Mount media share
sudo mkdir -p /media/nfs-media
sudo mount -t nfs -o ro 192.168.1.10:/nfs/media /media/nfs-media

# Now stream media from any device! ๐ŸŽฌ
vlc /media/nfs-media/movies/favorite-movie.mp4

Example 3: Automated Backup System

# On NFS Server - Create backup share
sudo mkdir -p /nfs/backups/$(hostname)
sudo chmod 700 /nfs/backups

# Restricted export for backup server only
echo "/nfs/backups 192.168.1.50(rw,sync,no_root_squash)" | sudo tee -a /etc/exports
sudo exportfs -arv

# On Backup Client - Create backup script
cat > ~/backup-to-nfs.sh << 'EOF'
#!/bin/bash
# Mount NFS backup share
sudo mount -t nfs 192.168.1.10:/nfs/backups /mnt/backup

# Perform backup
DATE=$(date +%Y%m%d)
tar -czf /mnt/backup/home-backup-$DATE.tar.gz ~/Documents ~/Pictures

# Unmount when done
sudo umount /mnt/backup

echo "Backup completed! โœ…"
EOF

chmod +x ~/backup-to-nfs.sh

# Schedule with cron
(crontab -l ; echo "0 2 * * * ~/backup-to-nfs.sh") | crontab -

๐Ÿšจ Fix Common Problems

Donโ€™t panic if something doesnโ€™t work! Here are solutions to common NFS issues:

Problem 1: Mount Command Hangs or Times Out

# Check if NFS server is running
sudo systemctl status nfs-server

# Verify firewall isn't blocking
sudo firewall-cmd --list-all

# Test connectivity to NFS ports
telnet SERVER_IP 2049  # NFSv4 port
rpcinfo -p SERVER_IP    # List all RPC services

# Check if exports are visible
showmount -e SERVER_IP

# If still hanging, try NFSv3 explicitly
sudo mount -t nfs -o vers=3 SERVER_IP:/nfs/share /mnt/point

# Enable verbose output for debugging
sudo mount -v -t nfs SERVER_IP:/nfs/share /mnt/point

Problem 2: Permission Denied Errors

# Check export permissions
sudo exportfs -v | grep share_name

# Verify directory permissions on server
ls -la /nfs/share_name

# Check if root_squash is the issue
# If yes, either use no_root_squash or change ownership

# Fix ownership on server
sudo chown -R nfsnobody:nfsnobody /nfs/share

# Or modify exports for no_root_squash
sudo nano /etc/exports
# Change root_squash to no_root_squash

# Re-export after changes
sudo exportfs -arv

Problem 3: Stale NFS File Handle

# This happens when server restarts or files are moved

# First, try remounting
sudo umount -f /mnt/nfs/share
sudo mount -t nfs SERVER_IP:/nfs/share /mnt/nfs/share

# If umount fails with "device busy"
sudo umount -l /mnt/nfs/share  # Lazy unmount

# Find processes using the mount
lsof | grep /mnt/nfs/share

# Kill stubborn processes if needed
sudo fuser -km /mnt/nfs/share

# Clear NFS cache on client
sudo systemctl restart nfs-client.target

๐Ÿ“‹ Simple Commands Summary

Your NFS command cheat sheet! ๐Ÿ“š Keep this handy:

TaskCommandWhat It Does
Start NFS Serversudo systemctl start nfs-serverStarts NFS service ๐Ÿš€
Stop NFS Serversudo systemctl stop nfs-serverStops NFS service ๐Ÿ›‘
Show Exportssudo exportfs -vLists all exports ๐Ÿ“‹
Apply Exportssudo exportfs -arvRefreshes exports ๐Ÿ”„
Check Mountsshowmount -e SERVERShows available shares ๐Ÿ‘€
Mount Sharesudo mount -t nfs SERVER:/path /mntMounts NFS share ๐Ÿ”—
Unmount Sharesudo umount /mnt/shareUnmounts share ๐Ÿ”“
List Mounts`mountgrep nfs`
NFS StatsnfsstatShows NFS statistics ๐Ÿ“ˆ
Check Servicesrpcinfo -pLists RPC services โœ…
Debug Mountmount -v -t nfsVerbose mount info ๐Ÿ”
Force Unmountumount -f /mntForces unmount ๐Ÿ’ช

๐Ÿ’ก Tips for Success

Here are my battle-tested tips for NFS excellence! ๐ŸŽฏ

Performance Optimization:

  • โšก Use async for non-critical data - Much faster writes
  • ๐Ÿš€ Increase rsize/wsize - Larger buffers for big files
  • ๐Ÿ“Š Monitor with nfsstat - Identify bottlenecks
  • ๐ŸŽฏ Use dedicated network - Isolate NFS traffic
  • ๐Ÿ’พ Consider SSD storage - Dramatic speed improvement
  • ๐Ÿ”ง Tune kernel parameters - Adjust for your workload
  • ๐Ÿ“ˆ Use NFS v4.2 - Latest features and performance
  • ๐ŸŒŸ Enable jumbo frames - For 10Gb+ networks

Security Best Practices:

  • ๐Ÿ” Use root_squash by default - Prevents root access abuse
  • ๐Ÿ›ก๏ธ Restrict by IP/subnet - Donโ€™t use wildcards in production
  • ๐Ÿ”’ Enable Kerberos - For sensitive environments
  • ๐Ÿ“ Regular audit exports - Remove unused shares
  • ๐Ÿšซ Avoid no_root_squash - Unless absolutely necessary
  • ๐ŸŽฏ Use read-only where possible - Minimize write access
  • ๐Ÿ” Monitor access logs - Watch for suspicious activity

๐Ÿ† What You Learned

Incredible work! Look at what youโ€™ve mastered! ๐ŸŽŠ

Your Achievements:

  • โœ… Installed and configured NFS server
  • โœ… Created and organized shared directories
  • โœ… Configured detailed export rules
  • โœ… Set up NFS clients successfully
  • โœ… Implemented automatic mounting
  • โœ… Optimized for different use cases
  • โœ… Solved common NFS problems
  • โœ… Applied security best practices
  • โœ… Created real-world examples
  • โœ… Mastered network file sharing!

๐ŸŽฏ Why This Matters

Your NFS setup isnโ€™t just file sharing - itโ€™s a unified storage solution! ๐ŸŒŸ

With NFS mastery, you can now:

  • ๐Ÿข Centralize company data - One source of truth
  • ๐Ÿ’ป Share development environments - Consistent across teams
  • ๐ŸŽฌ Stream media library - Access from any device
  • ๐Ÿ’พ Centralize backups - Simplified disaster recovery
  • ๐Ÿš€ Scale storage easily - Add space in one place
  • ๐Ÿ”ง Simplify maintenance - Manage files centrally
  • ๐Ÿ‘ฅ Improve collaboration - Real-time file sharing
  • โšก Boost productivity - No more file copying!

Remember when we started and NFS seemed complex? Now youโ€™re running a professional network file system that rivals enterprise solutions! Youโ€™ve transformed isolated machines into a unified network with seamless file access. Thatโ€™s absolutely incredible! ๐ŸŒŸ

Keep exploring, keep sharing, and most importantly, enjoy your new network storage superpowers! ๐Ÿฆธโ€โ™‚๏ธ

Happy file sharing, and welcome to the world of unified network storage! ๐Ÿ™Œ


P.S. - Donโ€™t forget to regularly back up your NFS exports configuration. Itโ€™s your map to the treasure! โญ