Written By :

Category :

Ops

Posted On :

Share This :

The Ultimate Guide to NFS Shares on Rocky Linux 9

Introduction

Network File System (NFS) is an essential component for file sharing in Linux environments. In this comprehensive guide, we will walk you through the process of setting up an NFS shares on Rocky Linux 9, a popular Linux distribution. Our step-by-step instructions will ensure you can easily install, configure, and test your NFS Shares on Rocky Linux 9, and allow all users and groups within a specified subnet. For more information about NFS, visit the official NFS documentation at https://docs.oracle.com/cd/E19683-01/816-4882/.

What is NFS and How is it Useful?

Network File System (NFS) is a distributed file system protocol that allows users to access files over a network as if they were locally stored on their machines. This makes sharing and collaboration more efficient by reducing the need for data transfers and providing a centralized storage solution. NFS is particularly useful in Linux environments and offers several benefits, such as faster data access, improved security, and reduced network traffic. To learn more about NFS, visit the Linux NFS-HOWTO page at https://tldp.org/HOWTO/NFS-HOWTO/.

NFS vs. SMB: What Are the Differences?

NFS and Server Message Block (SMB) are both network file sharing protocols. While NFS is primarily used in Linux and Unix environments, SMB is designed for Windows systems. NFS offers better performance and lower overhead, making it ideal for Linux systems, while SMB provides seamless integration and compatibility with Windows networks. Each protocol has its pros and cons, and the choice depends on your specific network requirements and system configurations. To learn more about the differences between NFS and SMB, visit this comparison article at https://www.acronis.com/en-us/articles/nfs-vs-smb/.

Step-by-Step Guide: NFS Shares on Rocky Linux 9

nfs shares on rocky linux 9
nfs shares on rocky linux 9

Step 1: Install NFS packages

To set up an NFS shares on Rocky Linux 9, first install the necessary packages by running the following command:

sudo dnf install nfs-utils

Step 2: Configure the NFS shares

sudo mkdir /path/to/your/shared/directory

Next, edit the /etc/exports file to configure the NFS shares. Open the file using a text editor:

sudo vim /etc/exports

Add the following line, replacing the path, subnet, and options with your specific values:

/path/to/your/shared/directory SUBNET/MASK(options)

For example, to share a directory with all users and groups within the 192.168.1.0/24 subnet, you would add:

/path/to/your/shared/directory 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check,no_all_squash)

Save and exit the file.

Step 3: Start and enable the NFS service

Start the NFS service and enable it to start at boot:

sudo systemctl start nfs-server
sudo systemctl enable nfs-server

Step 4: Configure the firewall

To allow NFS traffic through your firewall, execute the following commands:

sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --reload

Step 5: Mount the NFS shares on the client

To mount the NFS shares on a client machine, first install the nfs-utils package:

sudo dnf install nfs-utils

Create a directory to mount the NFS shares:

sudo mkdir /path/to/mount/point

Mount the NFS shares using the following command, replacing the IP address, shared directory path, and mount point with your specific values:

sudo mount SERVER_IP:/path/to/your/shared/directory /path/to/mount/point

To mount the NFS shares at boot, add an entry to the /etc/fstab file:

sudo vim /etc/fstab

Add the following line, replacing the IP address, shared directory path, mount point, and file system type with your specific values:

SERVER_IP:/path/to/your/shared/directory /path/to/mount/point nfs defaults 0 0

Save and exit the file.

Step 6: Test the NFS shares

To test your NFS shares, create a file in the shared directory on the server:

echo "Hello, NFS!" | sudo tee /path/to/your/shared/directory/test.txt

Now, check if the file is accessible from the client machine:

cat /path/to/mount/point/test.txt

If the output is “Hello, NFS!”, your NFS shares are working correctly.

Common Errors and Solutions

  1. “mount.nfs: access denied by server while mounting”

This error occurs when the client is unable to access the NFS shares. Ensure the server’s firewall is configured to allow NFS traffic and that the client’s IP address or subnet is specified correctly in the /etc/exports file.

  1. “mount.nfs: requested NFS version or transport protocol is not supported”

This error indicates that the client is requesting an unsupported NFS version or transport protocol. Check the server’s NFS configuration and ensure it supports the requested version or protocol. Update the client’s NFS configuration if necessary.

Conclusion

Setting up an NFS shares on Rocky Linux 9 is an efficient way to enable file sharing across your network. By following this guide, you can easily install, configure, and test your NFS shares, granting access to all users and groups within a specified subnet. To further enhance your understanding of NFS, refer to the provided resources and be sure to address any common errors you may encounter during the process.

Like this post? Check out our Ops section!

Leave a Reply