How to install and configure NFS Server on Linux RHEL/CentOS 6

Posted: February 17, 2014 in NFS
Tags: ,

NFSNetwork File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network much like local storage is accessed.

 

 

 

The most notable benefits that NFS provides are:

  • Data that would otherwise be duplicated on each client can be kept in a single location and accessed by clients on the network.
  • User home directories can be stored in one location and accessed by their owners over the network.
  • Administration of NFS exports is also simplified. For example, there is only one file system where security or backup policies must be set.
  • Transparent access to remote file system
  • Uses RPC for communications

Install Server

[root@nfs~]# yum -y install nfs-utils nfs-utils-lib
[root@nfs~]# vim /etc/idmapd.conf

# line 5: uncomment and change to your domain name
Domain = example.com

[root@nfs~]# vim /etc/exports

# Write like below *note
/shared 10.10.12.0/24(rw,sync,no_root_squash,no_all_sqush)

# *note

/shared                            = shared directory
10.10.12.0/24                  = range or networks NFS permits access
rw                                       = read and write access
sync                                    = synchronize
no_root_squash              = enable root privileges
no_all_squash                 = enable user’s authority

To Start nfs
[root@nfs~]# /etc/rc.d/init.d/nfs start
Starting rpcbind:  [OK]

Confirm export(s)
[root@nfs~]# exportfs -v

Client Side Configuration

Install NFS Packages and start NFS Servic

Install NFS packages using the below command

[root@nfsclient~]# yum install nfs-utils nfs-utils-lib -y
[root@nfsclient~]# vim /etc/idmapd.conf

# line 5: uncomment and change to your domain name
Domain = example.com

To Start nfs
[root@nfsclient~]# /etc/rc.d/init.d/nfs start
Starting rpcbind:  [OK]

Make it Start automatically after boot
[root@nfsclient~]# chkconfig nfs on

To find out which directories are shared put the below command

[root@nfsclient~]# showmount -e 10.10.12.143
where 10.10.12.143 is the nfs server ip address

Mount the Shared Directories

Mount Shared NFS directory using mount command. Note: First create a directory for mount point

[root@nfsclient~]# mkdir /nfsshared
[root@nfsclient~]# mount -t nfs 10.10.12.143:/shared /nfsshared

To verify use the below command on your command prompt

[root@nfsclient~]# mount

Setup Mount points so that they’re available upon reboot. To do that create and entry in /etc/fstab.

[root@nfsclient~]# vim /etc/fstab
10.10.12.143:/shared /nfsshared nfs defaults 0 0

Unmount and confirm that NFS mount points will be available when the client
system changes runlevels (reboots, starts, etc.) – ‘mount -a’

Comments
  1. Ganesh Ponna says:

    Hallo,

    Great post. Well though out. This piece reminds me when I was starting out after graduating from college.

    I’m still new to Linux and haven’t used it in a long time. Right now I have Mint 12 on my computer and I know it is not supported any longer. What I need to know is what should I upgrade to? Can I do it online or do I need to get a cd? Any help would be greatly appreciated as I want to get back into Linux.
    Please keep providing such valuable information.

    Thanks,

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.