Introduction:
Network File System (NFS) allows you to share directories between multiple servers over a network. It provides a convenient way to centralize storage and enable easy access to files across different systems. In this article, we will guide you through the process of setting up an NFS mount on Rocky Linux 8, enabling you to share and access files seamlessly.
Step 1: Install NFS Packages:
The first step is to install the necessary NFS packages on your Rocky Linux 8 server. Open a terminal and execute the following command:
sudo dnf install nfs-utils
This command will install the NFS utilities and dependencies required to set up the NFS mount.
Step 2: Configure the NFS Server:
Next, we need to configure the NFS server to share the desired directory. Open the NFS server configuration file using a text editor:
sudo vi /etc/exports
In this file, specify the directory you want to share and the client(s) that can access it. For example, to share the /shared_directory
with a specific client IP (e.g., 192.168.1.100), add the following line:
/shared_directory 192.168.1.100(rw,sync,no_root_squash)
Save the file and exit the text editor.
Step 3: Export the NFS Share:
After configuring the NFS server, export the share by running the following command:
sudo exportfs -rav
This command reads the /etc/exports
file and exports the specified directories.
Step 4: Start and Enable NFS Services:
To start the NFS server and enable it to start automatically at boot, run the following commands:
sudo systemctl start nfs-server sudo systemctl enable nfs-server
Step 5: Configure the NFS Client:
Now, on the client machine(s) that need to access the NFS share, ensure that the NFS packages are installed. Use the following command to install the NFS utilities:
sudo dnf install nfs-utils
Step 6: Mount the NFS Share:
Create a directory on the client machine where you want to mount the NFS share. For example:
sudo mkdir /mnt/nfs_share
To mount the NFS share, use the following command:
sudo mount <NFS_server_IP>:/shared_directory /mnt/nfs_share
Replace <NFS_server_IP>
with the IP address or hostname of the NFS server.
Step 7: Verify the NFS Mount:
To verify that the NFS share is mounted correctly, navigate to the mount point directory on the client machine and check its contents:
cd /mnt/nfs_share ls -l
You should see the files and directories from the NFS server listed.
Step 8: Configure Automatic Mount at Boot (Optional):
If you want the NFS share to be mounted automatically at boot, edit the /etc/fstab
file on the client machine and add the following line:
<NFS_server_IP>:/shared_directory /mnt/nfs_share nfs defaults 0 0
Save the file and exit the text editor.
Conclusion:
Congratulations! You have successfully set up an NFS mount on Rocky Linux 8, allowing you to share and access files across multiple servers. NFS provides a flexible and efficient solution for centralized storage and collaboration. Make sure to adjust the NFS server configuration and client settings according to your specific requirements. Remember to secure your NFS setup by configuring appropriate access controls and firewall rules. Happy sharing with NFS!