How to share a storage drive on Linux using NFS

Home > Search > How-to
  by

Install

Use the apt-get or yum command to install NFS

~]# 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

 


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

 

Start and enable NFS.

~]# systemctl start nfs
~]# systemctl enable nfs
~]# systemctl status nfs

 


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



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments