Friday, March 1, 2013

Install and Configure NFS

If we need to mount /mntsource on NFS server 192.168.1.1 to /mntclient on remote client machine 192.168.1.2, use the following method. You can also mount sub-directories, like /mntsource/dir1/dir2 --> /mntclient/dir1/dir2/dir3

On server 192.168.1.1

Install nfs and portmap softwares

yum install nfs-utils nfs-utils-lib portmap

Check nfsd module is loaded in the kernel.

[root@server ~]# lsmod | grep -i nfs
nfsd 177170 13
lockd 51571 1 nfsd
nfs_acl 1635 1 nfsd
auth_rpcgss 26415 1 nfsd
exportfs 2414 1 nfsd
sunrpc 137004 13 nfsd,lockd,nfs_acl,auth_rpcgss

If its not present, insert it to kernel.
modprobe nfsd

Add this to /etc/rc.local so that on every boot this module is loaded
What we need:
192.168.1.1 (/mntsource) --> 192.168.1.2 (/mntclient)
service portsentry stop
service portmap start
service nfs start
Add in /etc/exports on the nfs server to mount from remote server 192.168.1.2 to nfs server

/mntsource 192.168.1.2(ro,no_root_squash)
or
/mntsource 192.168.1.2(rw,sync)

Then run
exportfs -a

On remote client machine (192.168.1.2)
yum install nfs-utils nfs-utils-lib portmap
service portsentry stop
service portmap start
Mount to source NFS server
mount -t nfs 192.168.1.1:/mntsource /mntclient
Use df command to see if mounted
df -h

If you need to get this done all time when the system boots, add the following to the /etc/fstab file
192.168.1.1:/mntsource /mntclient nfs soft,nfsvers=2 0 0
NOTE: The value of nfsvers may change with the nfs server version

No comments:

Post a Comment