Bootstrap FreeKB - NFS - Share a storage drive on Linux using NFS (Network File System)
NFS - Share a storage drive on Linux using NFS (Network File System)

Updated:   |  NFS articles

Install

On a Red Hat distribution (CentOS, Fedora, Red Hat), dnf install or yum install can be used to install the NFS Utilities package. On a Debian distriubtion (Mint, Ubuntu), apt-get install can be used.

yum install nfs-utils

 


Firewall

If using iptables, allow NFS.

iptables -I INPUT -p 2049 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

 

If using Firewalld, allow NFS.

firewall-cmd --add-service=nfs --permanent
firewall-cmd --reload

 

If running an Amazon Web Services (AWS) EC2 instance, ensure the Security Group allows NFS inbound.

 


Configuration

Let's say you want to share /var/myShare. Edit the /etc/exports file, and add the following. In this example, only a single client is allowed to mount the share, client1.example.com. * can be used to allow any client to mount the share.

/var/myShare     client1.example.com(rw,sync,all_squash,no_subtree_check)

 

Export the new addition.

exportfs -a

 

The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.

If your system is using systemd, use the systemctl command to start and enable nfs.

systemctl enable nfs
systemctl start nfs
systemctl status nfs

 

If your system is using init, use the chkconfig and service commands to start and enable nfs.

chkconfig nfs on
service nfs start
service nfs status

 


You can now access this share from a different computer in our LAN.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 30ecc3 in the box below so that we can be sure you are a human.