Tutorial: How to set up an NFS Server on CentOS

You can convert a plain CentOS machine into an NFS server by installing the NFS Linux packages and configuring access to the shared directories. Here’s a simple step-by-step guide to help you get this set up.

Step 1 – Download and Install the Required NFS Software

Start by downloading and installing the required NFS packages.

[bash]yum -y install nfs-utils nfs-utils-lib [/bash]

Start the appropriate NFS services.

[bash]chkconfig nfs on
service rpcbind start
service nfs start[/bash]

Step 2 – Export Appropriate Shared Directories

Next step is to export appropriate directories on your NFS server so that they are accessible via NFS clients. You do this by adding the appropriate directory to /etc/exports file, which specifies both the directory to be shared and the details of how it is shared.

Edit the /etc/exports file:

[bash]vi /etc/exports[/bash]

Add the following line to the file:

/foo 10.1.10.100(rw,sync,no_root_squash,no_subtree_check,insecure)

where /foo is the directory you are trying to export.

  • rw: This option allows the client server to both read and write within the shared directory
  • sync: Sync confirms requests to the shared directory only once the changes have been committed.
  • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  • no_root_squash: This phrase allows root to connect to the designated directory
  • insecure: The default NFS setting is “secure” which requires that requests originate on an Internet port less than IPPORT_RESERVED (1024). To turn this setting off, specify insecure.

(NOTE: depending on your use case, either all or some of these options will make sense. For more information please reference NFS documentation.)

Add entries to the /etc/exports file for each directory you wish to export.

Once that’s done, export the directories:

[bash]exportfs -a[/bash]

 

The browser you are using is outdated. For the best experience please download or update your browser to one of the following:

Learn the FinOps best practices to maximize your cloud usage & budget:Register Now
+