Sunday, 12 April 2015

Configuring NFS (Network File System) on Rhel7/CentOS7

Nfs Server Ip Address :

Nfs Client Ip Address :

 Server  Configuration

1) Install NFS Server
            sudo yum install -y nfs-utils

2) Create a directory to share
            sudo mkdir -p /var/pub/data

3) Create file in directory to share
             sudo touch /var/data/pub/foo2

4) Make entry of directory to share in /etc/exports
            sudo vi /etc/exports
              where ro = Read only permission
              and rw = Read & Write permission

5) Export shared directory
              sudo exportfs -a 

6) To view exported directory

              sudo exportfs -v

7) Open nfs service in firewall
              sudo firewall-cmd --zone=public --add-service=nfs --permanent
              sudo firewall-cmd --zone=public --add-port=111/tcp --permanent
              sudo firewall-cmd --zone=public --add-port=111/udp --permanent
              sudo firewall-cmd --zone=public --add-port=20048/tcp --permanent 
              sudo firewall-cmd --zone=public --add-port=20048/udp --permanent 
              sudo firewall-cmd --reload

8) Start the service
              sudo systemctl start nfs 

Client Configuration

1) Install NFS Service
            sudo yum install -y nfs-utils

2) View nfs server's export list
              sudo showmount -e

3) Mount shared folder to use
              sudo mount -t nfs /mnt
              ls /mnt

4)To mount shared directory at boot time
      4.1)Add entry in /etc/fstab
                      sudoedit /etc/fstab 

                   /mnt        nfs     defaults        0 0

      4.2) To verify  /etc/fstab entry
              sudo umount /mnt
           sudo mount  /mnt

5) To mount the shared directory automatically (Configure Automounter)
     5.1) Make entry in /etc/auto.misc
               sudoedit /etc/auto.misc

               shared          -ro,soft,intr 
    5.2) Start service autofs
                  sudo systemctl start autofs

    5.3) To enable service autofs at boot time
                  sudo systemctl enable autofs

    5.4) View shared directory
                  ls /misc/shared

No comments:

Post a Comment