RHEL BasedRocky Linux

How To Install NFS Server on Rocky Linux 9

Install NFS Server on Rocky Linux 9

In this tutorial, we will show you how to install NFS Server on Rocky Linux 9. Network File System (NFS) is a distributed file system protocol that allows you to mount remote directories on your server. This enables you to manage storage space in a different location and write to that space from multiple machines. NFS provides a relatively standard and performant way to access remote systems over a network, making it a crucial tool for system administrators.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step setting up the NFS Server on Rocky Linux 9 or RHEL-based.

Prerequisites

  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for NFS Server.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install NFS Server on Rocky Linux 9

Step 1. Keeping your system updated is a crucial practice in maintaining a secure and stable environment. Before installing any new software, it’s recommended to update the system. On Rocky Linux 9, you can update your system using the following command:

sudo dnf update

Step 2. Installing NFS Server.

The first step in setting up an NFS mount is to install the necessary components. On Rocky Linux 9, you can install the NFS server daemon and its dependencies using the following command:

sudo dnf install nfs-utils

After installing the necessary packages, start, enable, and verify the status of the NFS server with these commands:

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

These commands ensure that the NFS server is running and will start automatically on system boot.

Step 3. Configuring NFS Exports.

Once the NFS server is installed and running, the next step is to configure the NFS exports. This involves specifying which directories on your server should be accessible to other machines on the network. To do this, you’ll need to edit the NFS configuration file, typically located at /etc/exports.

Each line in the /etc/exports file corresponds to an NFS share. The syntax for each line is as follows:

/share_name client1(permissions) client2(permissions)

Here, /share_name is the absolute path of the shared directory, client1 and client2 are the clients authorized to access the resources, and (permissions) are the permissions granted to each client.

Step 4. Firewall Configuration.

Before you can use the new shares, you need to ensure that traffic to the shares is permitted by firewall rules. If you are running a firewalld firewall, you can add the necessary services with the following commands:

sudo firewall-cmd --add-service={nfs,nfs3,mountd,rpc-bind} --permanent
sudo firewall-cmd --reload

These commands add the necessary services to the firewall and reload the firewall configuration to apply the changes.

Step 5. Mounting NFS Shares on the Client.

After setting up the NFS server, the next step is to mount the NFS shares on the client machine. This involves creating a mount point on the client and then using the mount command to mount the remote directory at that location.

To create a mount point, use the mkdir command:

mkdir /mnt/nfs_share

Then, use the mount command to mount the remote directory:

mount -t nfs server:/share_name /mnt/nfs_share

Here, server is the hostname or IP address of the NFS server, /share_name is the path of the shared directory on the server, and /mnt/nfs_share is the mount point on the client.

Step 6. Troubleshooting NFS Mounts.

Despite careful setup, you may encounter issues with NFS mounts. Here are some common problems and their solutions:

  • NFS mount not connecting on startup or reboot: If the NFS mount does not connect automatically on startup or reboot, you may need to add the _netdev option to the mount options in the /etc/fstab file. This option tells the system to wait until the network is up before attempting to mount the NFS share.
  • Permission issues: If you encounter permission issues, ensure that the directory permissions on the server match the NFS permissions. The NFS server preserves the client user UIDs and GIDs by default, except for root. To force the use of a different UID or GID, specify the anonuid=UID and anongid=GID options in the /etc/exports file.
  • Performance issues: If you experience slow performance with NFS, you may need to adjust the block size setting or the number of NFS daemons (nfsd). You can also tune the NFS client and server TCP stacks for better performance.

Congratulations! You have successfully set up the NFS Server. Thanks for using this tutorial for installing the R and NFS Server on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official NFS Server website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button