NFS server on CentOS8
NFS server on CentOS8
Install and configure NFS server
Step 1: Install NFS Packages:
Open a terminal on your CentOS 8 VM.
Run the following command to install the necessary NFS packages using
1
sudo yum install nfs-utils
Step 2: Configure NFS Exports:
Create a directory that will be shared with NFS clients. For example, let’s create a directory called /shared
1
sudo mkdir /sharedAssign appropriate permissions to the shared directory:
1
sudo chmod -R 777 /sharedOpen the
/etc/exportsfile in a text editor:1
sudo vi /etc/exportsAdd an entry in the file to define the shared directory and specify the allowed NFS clients. For example:
1
/shared 192.168.1.0/24(rw,sync,no_root_squash)/shared: Path to the directory you created.192.168.1.0/24: IP address range or specific IP of the NFS clients allowed to access the shared directory.rw: Allows read and write access.sync: Synchronizes changes to the disk before acknowledging the request.no_root_squash: Allows the root user on the NFS client to have root privileges on the NFS server.
Step 3: Start and Enable NFS Services:
Start the NFS server service:
1
sudo systemctl start nfs-serverEnable the NFS server service to start automatically at boot:
1
sudo systemctl enable nfs-server
Step 4: Configure Firewall for NFS:
If you have a firewall enabled, open the necessary ports for NFS:
1
2
3
4sudo firewall-cmd --permanent --zone=public --add-service=nfs
sudo firewall-cmd --permanent --zone=public --add-service=mountd
sudo firewall-cmd --permanent --zone=public --add-service=rpc-bind
sudo firewall-cmd --reload
Step 5: Export the Shared Directory:
Export the shared directory by running the following command:
1
sudo exportfs -r
Step 6: Test NFS Access:
On a client machine, ensure that the NFS utilities package is installed. If not, install it using
sudo dnf install nfs-utils.Create a directory on the client machine where you want to mount the NFS share. For example, let’s create a directory called
/mnt/nfs1
sudo mkdir /mnt/nfsMount the NFS share from the server to the client:
1
sudo mount server_ip:/shared /mnt/nfs- Replace
server_ipwith the IP address of your NFS server.
- Replace
Verify that the NFS share is mounted successfully by accessing the
/mnt/nfsdirectory on the client.
Access NFS server shared folder from windows
Step 1: Enable NFS Client Feature:
- Open the “Control Panel” on your Windows machine.
- Go to “Programs” or “Programs and Features”.
- Click on “Turn Windows features on or off”.
- Scroll down and locate “Services for NFS”.
- Check the box next to “Client for NFS”.
- Click “OK” and wait for the feature to be installed.
Step 2: Mount the NFS Share:
Open the “File Explorer” on your Windows machine.
In the address bar, enter the following command, replacing
nfs_server_ipwith the IP address of your NFS server andshared_directorywith the path to the shared directory on the NFS server:1
\\nfs_server_ip\shared_directoryFor example:
1
\\192.168.1.100\sharedPress Enter or click on the arrow button to access the NFS share.
If prompted, enter the appropriate credentials to access the NFS share (if the NFS server requires authentication).
Optional: Use web browser to access the shared folder:
