CentOS / Redhat: Setup NFS v4.0 File Server

Here is how you can set up an NFS v4.0 file server on CentOS or Red Hat:

  1. Install the NFS server software:
sudo yum install nfs-utils
  1. Create a directory that you want to share as the NFS file system:
sudo mkdir /path/to/nfs/shared/directory
  1. Change the ownership and permissions of the directory:
sudo chown nfsnobody:nfsnobody /path/to/nfs/shared/directory
sudo chmod 755 /path/to/nfs/shared/directory
  1. Add the following entry to the /etc/exports file to export the NFS file system:
/path/to/nfs/shared/directory *(rw,sync,no_root_squash,no_all_squash)
  1. Start and enable the NFS server:
sudo systemctl start nfs-server
sudo systemctl enable nfs-server
  1. Verify that the NFS server is working by running the following command:
showmount -e localhost

This will display the list of NFS file systems exported by the NFS server. If you see your shared directory in the list, then the NFS server is set up correctly.

Note that the above steps assume a basic NFS setup and do not include advanced configurations such as firewall rules or SELinux policies. You may need to adjust these based on your specific requirements.

Leave a Comment