Network File System

NFS(Network File system)

Nfs-Server 192.168.10.1

NFS-Client 192.168.10.2

Services:

rpcbind: convert RPC program numbers into universal addresses

nfs-server: It enables clients to access NFS shares

nfs-lock/rpc-statd: NFS file locking. Implement file lock recovery when NFS server crashes and reboots

nfs-idmap: It translates user and Group names into id’s; user and group id’s into names.

/etc/exports: It is main configuration file, controls which file systems are exported to remote hosts with options

/etc/fstsb: This file used to control what file system including NFS Directories are mounted when system boots.

/etc/sysconfig/nfs: this file is used to control which ports the required RPC services run.

/etc/hosts.allow, /etc/hosts.deny: It controls access to NFS server. It is used by NFS to decide whether accept connection from another IP address. These files are also called TCP wrappers.

Port 2049 should be enabled, SELinux disabled

 

Installation of NFS Server:

#yum –y install nfs-utils libnfsidmap

#systemctl enable rpcbind

#systemctl enable nfs-server

#systemctl start rpcbind

#systemctl start nfs-server

#systemctl start rpc-statd

#systemctl start nfs-idmapd

 

Create NFS Share Directory:

/nfsshare

#mkdir nfsshare

#chmod 777 /nfsshare

 

Modify configuration file add below line(client ip address):

#vim /etc/exports

/nfsshare 192.168.0.2(rw,sync,no_root_squash)

 

#exportfs –r

To See list of shared files and export option on server:

#exportfs –v

To exports all directories listed in /etc/exports

#exportfs –a

To unexport one or more Directories:

#exportfs –u

To reexport all Directories after modifying /etc/exports

#showmount –e localhost

 

CONFIGURE NFS Client:

Install NFS packages on NFS client

#yum –y install nfs-utils libnfsidmap

#systemctl enable rpcbind

#systemctl start rpcbind

To mount NFS Shares on clients(server ip address):

#showmount –e 192.168.0.1

To create mount point to mount shared folder “/nfsshare”

#mkdir /nfsshare

#mount 192.168.0.1:/nfsshare /nfsshare

#df –hk

#mount

#cd /nfsshare

#touch test1 test2

 

Login into NFS-Server

#cd /nfsshare

You can see file is there

#ll

 

Login into NFS-Client:

To mount shares automatically after every reboot.

Modify /etc/fstab file, add below line

#vim /etc/fstab

192.168.0.1:/nfsshare /nfsshare nfs rw,sync,hard,intr 0 0

#mount –av

#umount /nfsshare

#mount –av

#df –hk

#reboot

To Re-verify

#mount

#df -kh

 

AutoFS

If we don’t want static mount

Shares are automatically accessed when user tries to access

Booting time is low.

To install autofs

On client

#yum –y install autofs

To configure autofs:

#vim /etc/auto.master

/mnt      /etc/auto.misc  –timeout=20

#vim /etc/auto.master

Change

/mnt      /etc/auto.misc  –timeout=20

 

#vim /etc/auto.misc

nfsshare              -fstype=nfs rw,soft,intr 192.168.0.1:/nfsshare

#systemctl enable autofs

#systemctl start autofs

It will not show any folder like nfsshare

#df –hk

#cd /mnt/nfs

#df –hk

This time you will see nfsshare

#cd /nfsshare