CentOS 6 – Create an NFS Share

This brief tutorial will demonstrate how to share files between Linux machines by creating an NFS share on CentOS 6. It also covers how to access the share from another CentOS 6 or Ubuntu/Debian machine.

Install needed packages

Make NFS Start on Boot

Export Directories that will be Shared

All of the directories that you want to share must be added to /etc/exports:

For this example, we’ll share /var/www/ with anyone on the local network. Add the following line to /etc/exports:

Let’s go over what each item means:

  • /var/www/ – The directory to share
  • 192.168.0.0/24 – Who is able to access the share. This can be a single IP address or a subnet mask can be used to allow a range of IPs. In this case, we’re using a subnet mask of /24 to give access to anyone from 192.168.0.1 to 192.168.255.255
  • rw – give users read and write access
  • sync – Any changes are immediately written to disk
  • no_subtree_check – Disables verification that the requested file is in exported tree
  • no_root_squash – Allows root users from other machines to access the share

Once you’ve finished editing /etc/exports you must update the exported filesystems table:

You now have a working NFS share. The next steps show how to access the share from a remote machine.

Accessing the Share

Install the NFS Client

Create the directory where we’ll mount the share

Mount the Share

Mount the Share at Boot

If you want to automatically mount the share when booting then add the following line to /etc/fstab:

Leave a Reply

Your email address will not be published. Required fields are marked *

×Mike Everhart

Need Some More Help? Let's Talk!

I'd love to work with you! Fill out the form below to schedule a free consultation to discuss your needs and how I can help.

Need More Help?