Setup NFS Server and Client in Rocky Linux 8

Introduction

Network File System (NFS) allows you to share directories and files across a network, enabling multiple systems to access common data as if it were stored locally. In this guide, we will configure an NFS server on Rocky Linux 8, set up client-side mounting on both Rocky Linux and Ubuntu, and demonstrate practical usage.

Step 1: Install NFS Server on Rocky Linux 8


    sudo dnf install nfs-utils -y
    sudo systemctl enable --now nfs-server
    

Step 2: Configure Export Directory

Create a shared directory and update NFS exports configuration:

    sudo mkdir -p /mnt/nfs_share
    sudo chown -R nfsnobody:nfsnobody /mnt/nfs_share
    sudo chmod 777 /mnt/nfs_share

    echo "/mnt/nfs_share 192.168.1.0/24(rw,sync,no_root_squash)" | sudo tee -a /etc/exports
    sudo exportfs -rav
    

Step 3: Adjust Firewall


    sudo firewall-cmd --permanent --add-service=nfs
    sudo firewall-cmd --permanent --add-service=mountd
    sudo firewall-cmd --permanent --add-service=rpc-bind
    sudo firewall-cmd --reload
    

Step 4: Client Configuration (Rocky Linux 8)

On the client system, install NFS utilities and mount the shared directory:

    sudo dnf install nfs-utils -y
    sudo mount -t nfs 192.168.1.100:/mnt/nfs_share /mnt
    

Step 5: Client Configuration (Ubuntu)

On Ubuntu clients, install the required package and mount the NFS share:

    sudo apt update
    sudo apt install nfs-common -y
    sudo mount -t nfs 192.168.1.100:/mnt/nfs_share /mnt
    

Step 6: Permanent Mount via fstab

To mount automatically on reboot, add the following line to /etc/fstab:

    192.168.1.100:/mnt/nfs_share  /mnt  nfs  defaults  0  0
    

Uses of NFS

  • Centralized file sharing for teams
  • Storing user home directories
  • Backup and recovery storage
  • Application data sharing in enterprise environments

Conclusion

By configuring an NFS server, administrators can efficiently share data between Rocky Linux and Ubuntu clients. With proper firewall and access controls, NFS is a reliable solution for centralized storage in both small and large-scale environments.

Leave a Reply

Your email address will not be published. Required fields are marked *