This article is going to take you through on how to Install NFS Server on Rocky Linux. NFS (Network File System) is a client/server program that allows a computer user to access, store, and update files on another computer. NFS is one of several Distributed File System (DFS) standards for network attached storage (NAS).
How to Install NFS Server on Rocky Linux
- Make sure your packages are up to date.
sudo dnf update
- Next set host name using the following command.
sudo hostnamectl set-hostname nfs.example.com --static
Install NFS Server
- After upgrading your packages and setting up your host name, you can now use the following command to install NFS server.
sudo dnf install nfs-utils
- Then start NFS using the command below.
sudo systemctl start nfs-server
- To make the NFS service start automatically when the computer starts up run the command below.
sudo systemctl enable nfs-server
- NFS should be up and running, check its status.
sudo systemctl status nfs-server
Sample output
● nfs-server.service - NFS server and services Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled) Active: active (exited) since Sat 2022-04-16 23:49:50 EAT; 41s ago Process: 57361 ExecStart=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS) Process: 57349 ExecStart=/usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS) Process: 57348 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS) Main PID: 57361 (code=exited, status=0/SUCCESS) Apr 16 23:49:50 localhost.localdomain systemd[1]: Starting NFS server and services... Apr 16 23:49:50 localhost.localdomain systemd[1]: Started NFS server and services.
Setup NFS directory share
- We’ll store files that will be shared across the local area network on the NFS directory share. It will be created in the /mnt/directory_name, create the directory using the following command.
sudo mkdir /mnt/my_data
- Next, assign proper ownership and permissions using the command below.
sudo chown nobody:nobody /mnt/my_data
sudo chmod -R 777 /mnt/my_data
Configure Exports for client
- Edit exports configuration file to allow client access. Open the exports config using the command below.
sudo nano /etc/exports
- Add client that can access the NFS server using the following line in the config file. Note, you can add several lines with different clients IP to add more clients.
/mnt/my_data CLIENT-IP/24(rw,sync,no_subtree_check)
The command above meaning;
- rw-Read and Write )
- sync-Write changes to disk before applying them)
- no_subtree_check-Avoid subtree checking )
Next export the shared directory.
sudo exportfs -ra
- Restart NFS server using the command below to apply changes.
sudo systemctl restart nfs-server.service
Allow NFS Share Access on Firewall
- Allow NFS with the following command if you’re using a firewall.
sudo firewall-cmd --permanent --add-port=2049/tcp
sudo firewall-cmd reload
- Reload the firewall to apply the changes.
sudo firewall-cmd --reload
Install and Configure NFS Client
- To begin, make sure your client packages are up to date.
sudo dnf update
- Use the command below to install the NFS client package.
sudo dnf install nfs-common
Mounting NFS Share on the Client
- The following command will create a directory in which the NFS share from the NFS server will be mounted.
sudo mkdir -p /mnt/client_directory
- After you’ve created the mount directory, run the command below to mount the remote NFS share directory.
sudo mount SERVER-IP:/mnt/my_data /mnt/client_directory
Test NFS Share
- Create a test file by navigating to your directory share on the NFS server.
cd /mnt/my_data
touch nfs_rocky.txt
- On your client system, list the contents of the mounted share directory.
ls /mnt/client_directory
The contents of the server should be accessible in the client directory.
- It’s a wrap, you have reached the end of the article. You now know how to Install NFS Server on Rocky Linux.
Other Tutorials
Install and configure Postfix as Send-Only SMTP on Debian 11
Install and Configure Postfix as Send-Only SMTP on Ubuntu 22.04