Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

NFS

(NETWORK FILE SYSTEM)

NFS (Network File System) is used to sharing the files and folders between linux to unix and
unix to linux machines,NFS was developed by Sun Mycro Systems in the year 1984.

Features:
1. Every one can access same data.

2. Reduce Storage Cost and Easy to use.

3. Centralized Management of Files.

4. Secured with Firewalls and Kerberos.

Mail: aleemsk@gmail.com Ph:9952590457


NFS Configuration :

 NFS Port Number : 2049 (for NFS)


: 111 Port Map

 Service Name : nfs

 Packages : i) nfs-utils
 ii) nfs-utils-lib

 Configuration File : /etc/exports


It is main Configuration file of NFS, define all exported files
and folders in this path.
: /etc/sysconfig/nfs
It is also Configuration file of NFS to controle on which port rpc
and other services are listening.

 status files

 /etc/exports
 /var/lib/nfs/rmtab
 /var/lib/nfs/xtab
 /etc/hosts.allow
 /etc/hosts.deny

 Daemons
 rpc.portmap

 rpc.mountd

 rpc.nfsd

 rpc.statd

 rpc.lockd

 rpc.rquotad

Mail: aleemsk@gmail.com Ph:9952590457


 Scripts and commands

 /etc/rc.d/init.d/nfs
 nfstat

 showmount

 rpcinfo

 exportfs

To setup NFS Server, we have at least two Linux Machines. one is NFS Server and another one
is NFS Client

NFS Server : 192.168.x.xx

NFS Client : 192.168.x.xx

Sever Side

To check the nfs RPM is installed or Not

# rpm -qa nfs-utils


# rpm -qa nfs-utils-lib

Install the NFS Packages using Yum

# yum install nfs-utils nfs-utils-lib -y

(or)

#yum install nfs* -y

Mail: aleemsk@gmail.com Ph:9952590457


To create directory.
# mkdir /oracle

To export directory.

#vim /etc/exports
/oracle *(rw,sync ,no_root_squash ,no_all_squash)
/oracle 192.168.0.0/24(ro,sync)

:wq

Note

rw – Writable permission to shared folder


ro -- Read-only permission to shared folder
sync – Synchronize shared directory
no_root_squash – Enable root privilege
ie-> root privileges are not restricted on NFS server in
no_root_squash.
root_squash -- client root cannot delete NFS folder.
no_all_squash – Enable user’s authority

#exportfs -r (Re exports the nfs share)

#service nfs restart

# chkconfig nfs --list


nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off

# exportfs -v
/oracle <world>(rw,wdelay,no_root_squash,no_subtree_check)
# ,

#chkconfig nfs on

# showmount -e 192.168.0.17

Mail: aleemsk@gmail.com Ph:9952590457


# exportfs -av
exporting 192.168.0.75:/oracle
exporting *:/kick
exporting *:/var/ftp/pub

# exportfs -u
/oracle 192.168.0.75
/var/ftp/pub <world>
/kick <world>
#

Client Side Configuration

Step 1: Install NFS Packages & start NFS service

Install NFS Packages using yum command

(I)
# yum install nfs-utils nfs-utils-lib -y

(II)
# yum install showmount rpcbind -y

# service nfs start

# chkconfig nfs on

Step2 : To findout which files or directories are exported from the server

# showmount -e 192.168.6.136
Export list for 192.168.6.136:
/oracle *
#

Step 3: Create a Directory

Mail: aleemsk@gmail.com Ph:9952590457


# mkdir /data

Step 4: Mount a directory from server to client

# mount -t nfs 192.168.6.136:/oracle /data ====> (Temporary Mount )

#mount

# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 18G 2.4G 15G 15% /
tmpfs tmpfs 495M 224K 495M 1% /dev/shm
/dev/sda1 ext4 291M 33M 243M 12% /boot
/dev/sr0 iso9660 3.5G 3.5G 0 100% /mnt
192.168.6.136:/oracle
nfs 18G 2.4G 15G 15% /data
#

Step 5: To check the directory

# cd /data

# chmod -R 777 /data

# ls
abc.txt

# cat abc.txt
this is test file for NFS
#

For permanent

#Vi /etc/fstab ====> (Permanent Mount )

192.168.6.134:/oracle /data nfs defaults 0 0

:wq

#mount -a

#cd /data

#ls

Mail: aleemsk@gmail.com Ph:9952590457


HARD MOUNT AND SOFT MOUNT

HARD mount :(Permonent Mounting)

If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the
server. The NFS daemon retries will not time out, will affect system performance, and you
cannot interrupt them

If you just mount a file system without specifying hard or soft, the default is a hard mount.
Hard mounts are preferable because of the stateless nature of NFS.

If a client sends an I/O request to the server (such as an ls -la), and the server gets
rebooted, in client machine the process will keep on running.
This preserves data transfers in the event of a server failure

ex:
Hard Mount (Permanent mounting):-
[root@sadeek~]# mount -o rw,hard,intr 172.28.50.109/nfs /mnt
[root@sadeek ~]# vim /etc/fstab
172.28.50.109:/nfs /mnt nfs Defaults 0 0
:wq!
We can check nfs share with the help of below mention command.
[root@sushee ~]# mount –a

SOFT Mount : (Temperory Mounting)

A soft mount allows the client to stop trying an operation after a period of time. If the NFS
server goes down at the time of data transfer , it will alert and the process will do
down.Thsi may cause the data corruption.
A soft link will return with an error and fail.

you should only use soft mounts in the cases where client responsiveness is more important
than data integrity.

In another word ..soft mount will allow automatic unmount if the filesystem is idle for a
specified time period

Mail: aleemsk@gmail.com Ph:9952590457


ex:

[root@sadeek ~]# showmount -e 172.28.50.109


Export list for 192.168.0.105:
/nfs *
Soft mounting (Temporary Mounting):-
[root@sadeek ~]# mount 172.28.50.109:/nfs/ /mnt/

Probles and Solution --- > (This is server side Problem)

[root@localhost ~]# service nfs restart


Shutting down NFS daemon: [FAILED]
Shutting down NFS mountd: [FAILED]
Shutting down NFS quotas: [FAILED]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection
refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS mountd: [FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd
[FAILED]

[root@localhost ~]# service rpcbind restart =====> To restart the rpcbind once
Stopping rpcbind: [FAILED]
Starting rpcbind: [ OK ]

[root@localhost ~]# service rpcbind restart


Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]

[root@localhost ~]# service nfs restart


Shutting down NFS daemon: [FAILED]
Shutting down NFS mountd: [FAILED]
Shutting down NFS quotas: [FAILED]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]

Mail: aleemsk@gmail.com Ph:9952590457


Starting NFS daemon: [ OK ]
[root@localhost ~]#

scniario2

Client side

[root@localhost ~]# showmount -e 192.168.6.136


clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

solution
server side :

1.Go to server side

2. #iptables -L

3.#iptables -F

or

# service iptables stop

# chkconfig iptables off

Now Client Side

#service nfs restart

#chkconfig nfs on

# showmount -e 192.168.6.136 Export list for 192.168.6.136:


/oracle *
#

Mail: aleemsk@gmail.com Ph:9952590457


To check the NFS Server or NFS Client

Mail: aleemsk@gmail.com Ph:9952590457


To check the NFS Version

NFS was originally developed by Sun Microsystems:


NFSv2 released in 1985
NFSv3 released in 1995
NFSv4 released in 2003 for Sun and NetApp. Available in Linux now.

# mount -v

desktop75.example.com:/java on /mnt type nfs


(rw,vers=4,addr=192.168.0.75,clientaddr=192.168.0.62)

Mail: aleemsk@gmail.com Ph:9952590457

You might also like