NFS offers service which can use the file which other remote hosts have as well as the file which a local host has. Portmapper should should be install and configure in order to start NFS service. The article below show the step by step NFS installation, the NFS server configuration and NFS client configuration.
Installation of NFS server
[root@tenouk ~]# mount /dev/cdrom
[root@tenouk ~]# cd /mnt/cdrom/RedHat/RPMS
[root@tenouk ~]# rpm –Uhv nfs-utils-0.3.1-13.i386.rpm
[root@tenouk ~]# cd /
[root@tenouk ~]# umount /dev/cdrom
Start and stop NFS service
[root@tenouk ~]# /sbin/service nfs start
[root@tenouk ~]# /sbin/service nfs stop
Setting of automatic start for NFS
Set automatically start for nfs on runlevel 3 and runlevel 5.
[root@tenouk ~]# /sbin/chkconfig –level 35 nfs on
Confirmation of automatic start
[root@tenouk ~]# /sbin/chkconfig --list nfs
nfs 0:off 1: off 2: off 3: on 4: off 5:on 6: off
[root@tenouk ~]#
Configure /etc/exports
File which sets which file or directory on NFS server other hosts can share
It is called export to put out permission to other hosts.
[root@tenouk ~]# vi /etc/exports
/home 10.10.0.0/255.255.0.0(rw)
The NFS mount is permitted to be done to the host who has belonged to 10.10.0.0/255.255.0.0 while possible to be read and written.
Configure /usr/sbin/exportfs
The content written in /etc/exports is moved to the export table.
[root@tenouk ~]# /usr/sbin/exportfs –a
All content written in /etc/exports is made effective.
[root@tenouk ~]# /usr/sbin/exportfs –v
The content of a present export table is displayed.
Confirmation of NFS mount
Which client does the NFS mount is confirmed.
[root@tenouk ~]# showmount
Host on localhost
192.168.0.199
[root@tenouk ~]#
Display the NFS mount directory.
[root@tenouk ~]# showmount –d
/home
/export
[root@tenouk ~]#
The directory and the client that the NFS mount is done are displayed.
[root@tenouk ~]# showmount –a
hostA:/home
192.168.0.2:/export
192.168.0.3:/export
[root@tenouk ~]#
Setting of NFS client
[root@tenouk ~]# mount –t nfs compaq:/export /mnt/nfs
(type)
Directory /export on NFS server compaq is done and the NFS mount is done to local host's /mnt/nfs.
Un mount NFS.
[root@tenouk ~]# umount /mnt/nfs
Automatic mount NFS filesystem
When starting, the mount is done when the NFS mount is described in /etc/fstab.
[root@tenouk ~]# vi /etc/fstab
hostA:/export /mnt/nfs mfs soft 0 0
The first field : Directory name on NFS server
The second field : Mount point on local host
The third field : Kind of filesystem
The fourth field : Mount option
The fifth field :
The sixth field :
Automount NFS
Installation of autofs is needed to make sure that the NFS is aoutmatically mount.
Confirmation on autofs installation.
[root@tenouk ~]# rpm -q autofs
Installation of autofs.
Install autofs using rpm package.
[root@tenouk ~]# mount /dev/cdrom
[root@tenouk ~]# cd /mnt/cdrom/RedHat/RPMS
[root@tenouk ~]# rpm -Uhv autofs-3.1.7-28.i386.rpm
[root@tenouk ~]# cd /
[root@tenouk ~]# umont /dev/cdrom
Start, stop and restart autofs.
[root@tenouk ~]# /sbin/service autofs start
[root@tenouk ~]# /sbin/service autofs stop
[root@tenouk ~]# /sbin/service autofs restart
Setting of autofs automatic start.
[root@tenouk ~]# /sbin/chkconfig --level 35 autofs on
Confirmation of autofs automatic start
[root@tenouk ~]# /sbin/chkconfig --list autofs
Setting which uses NIS
The configuration on the NIS server
[root@tenouk ~]# vi /etc/auto.master
/nfs /etc/auto.home --timeout 60
[root@tenouk ~]# vi /etc/auto.home
home -rw,hard,intr,nolock compaq:/home
[root@tenouk ~]# vi /var/yp/Makefile
all: passwd group hosts rpc services netid protocols mail \
shadow auto.home \
# netgrp shadow publickey networks ethers bootparams printcap \
# amd.home auto.master auto.home auto.local passwd.adjunct \
# timezone locale netmasks
Update of NIS data base
[root@tenouk ~]# cd /var/yp
[root@tenouk ~]# make
Setting on the NIS / NFS client side
Confirmation of auto.home
[root@tenouk ~]# ypcat auto.home
-rw,hard,intr,nolock compaq:/home
[root@tenouk ~]# vi /etc/auto.master
/nfs auto.home --timeout 60