Introduction

NFS (Network File System) allows you to share directories and files between systems over a network. In this guide, you will learn how to set up an NFS server and client on CentOS 9, which can be efficiently hosted on a Windows VPS UK for optimal performance.

Prerequisites

  • A CentOS 9 server with root access
  • Basic knowledge of Linux commands
  • An active internet connection

Step 1: Update Your System

Start by updating your package index:

sudo dnf update -y

Step 2: Install NFS Utilities

Install the NFS utilities package:

sudo dnf install nfs-utils -y

Step 3: Create a Directory to Share

Create a directory that you want to share over NFS:

sudo mkdir -p /mnt/nfs_share

Step 4: Configure NFS Exports

Edit the NFS exports file to specify which directory to share:

sudo nano /etc/exports

Add the following line to share the directory with specific clients:

/mnt/nfs_share *(rw,sync,no_root_squash)

This configuration allows any client to access the share with read and write permissions.

Step 5: Start the NFS Service

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

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

Step 6: Export the Shared Directory

Run the following command to export the shared directory:

sudo exportfs -a

Step 7: Configure Firewall

Allow NFS traffic through the firewall:

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

Step 8: Set Up NFS Client

On the client machine, install the NFS utilities:

sudo dnf install nfs-utils -y

Step 9: Create a Mount Point on the Client

Create a directory where the NFS share will be mounted:

sudo mkdir -p /mnt/nfs_client

Step 10: Mount the NFS Share

Mount the NFS share on the client:

sudo mount -t nfs server_ip:/mnt/nfs_share /mnt/nfs_client

Replace server_ip with the actual IP address of your NFS server.

Step 11: Verify the Mount

Check if the NFS share is mounted correctly:

df -h

Step 12: Automate Mounting at Boot (Optional)

To ensure the NFS share mounts automatically at boot, add the following line to /etc/fstab on the client:

server_ip:/mnt/nfs_share /mnt/nfs_client nfs defaults 0 0

Step 13: Conclusion

You have successfully set up an NFS server and client on CentOS 9. This configuration allows for efficient file sharing across systems, making it ideal for collaboration in environments like a Windows VPS. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for optimal performance and security.

© 2024 NFS Setup Tutorial. All rights reserved.

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)