NFS Server & Client Configuration – RHEL 6.4
- NFS, Network File System, is a server-client protocol used for sharing files between linux systems.
- NFS enables you to mount a remote share locally.
- You can then directly access any of the files on that remote share.
Let’s see how to configure NFS master server & client setup.
@ Master server, create a new file system (or directory) you wanted to share with other servers.
$ su – root
# mkdir /nfs_mast
** this is the directory we wanted to share to other linux clients.
Install NFS packages to configure NFS master server:
# yum groupinstall “NFS file server –> “Y” to install all listed packages.
Verify the NFS packages installed :
# rpm -qa | grep nfs
Start the NFS server & add the script in start-up
# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
# service nfs status (To check NFS services running)
# Remember NFS use TCP port “2049”, verify it is “LISTENING”
# netstat -an |grep 2049
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN
tcp 0 0 :::2049 :::* LISTEN
# chkconfig –levels 35 nfs on (this command turn on NFS only for run level 3 & 5)
# chkconfig nfs on (this command trun on NFS on 2,3,4 & 5)
# chkconfig –list | grep nfs (check the status)
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
NFS service is running & we are ready to share our directory “nfs_master”
Edit the NFS configuration file ” /etc/exports” & add the following entry
- /nfs_share is the directory you want to export.
- 192.168.1.100 is the client allowed to log in this directory.
- The ro option mean mounting read-only.
- The root_squash option for not allowing root write access in this directory.
- * (star means, everyone)
- rw (read & write)
When ever we edit/update configuration file, it is mandatory to restart the service (NFS) to take effect.
# service nfs restart (or stop/start)
Verify the directory being exported by NFS.
Now, NFS server setup is done & we are ready to login to client server and mount the NFS directory “nfs_server”
login to client linux server
# su – root
Verify what directory shared from server & NFS port status
# showmount -e “NFS server IP “
# telnet “server IP” 2049 (If it fails, you should check IPTABLES/firewall between servers)
All looks good, let us mount it.
# mkdir /nfs_share
#mount -t nfs 192.168.1.10:/nfs_share /nfs_share
#df -h (verify it is mounted)
Now you can write in to the NFS share.
Update /etc/fstab file at client server, other wise you will loose NFS mount during server restart.
vi /etc/fstab (add the following line)
192.168.1.1:/nfs_share /nfs_share nfs defaults 0 0