Step-by-step: Set up an NFS share

Published in: 

This article assumes you have NFS and portmap installed on your server already. I think a lot of distros come that way, but some of the links below the instructions mention installation steps if you need it. If you need to install for Redhat or Centos just do:
yum install nfs-utils nfs4-acl-tools portmap

I. First, setup the NFS server

(note: in the steps below 192.168.0.2 is the nfs client, and 192.168.0.3 is the nfs server)
1. mkdir /home/fileshare
2. Add this to /etc/exports on NFS server:
home/fileshare 10.181.229.183(rw,sync)
3. Add this to /etc/hosts.allow on NSF server
portmap: 192.168.0.2/255.255.255.255
portmap: 192.168.0.3/255.255.255.255
4. Check to make sure portmap is running correctly by doing:
/sbin/service portmap status
...check /var/log/messages for any error that might occur
5. Start nfs and portmap:
/etc/init.d/portmap
/etc/init.d/nfs
6. Make entry for the ip gets added to APF or else connection will timeout:
apf -a 192.168.0.2
7. Make sure services start on boot:
chkconfig nfs on
chkconfig portmap on

SPECIAL NOTES
1. If portsentry is on the server, make sure that it doesn't get in the way when trying to start portmap. If this an issue, comment out everywhere where '111' appears in /etc/portsentry/portsentry.conf (111 is the port that portmap uses) and stop and stop portsentry to reload (/etc/init.d/portsentry stop, /etc/init.d/portsentry start)
2. add ip of client server to /etc/portsentry/portsentry.ignore

II. Second, setup NFS client

1. Make shared directory on client
mkdir /home/fileshare
2. Add to /etc/fstab on client so will get mounted on reboot
192.168.0.3:/home/fileshare /home/fileshare nfs rw,hard,intr 0 0
3. Start portmap:
/etc/init.d/portmap
4. Make entry for the ip gets added to APF or else connection will timeout:
apf -a 192.168.0.3
5. Mount with:
mount -a
6. Make sure portmap starts on boot:
chkconfig portmap on


Other articles
http://linuxwave.blogspot.com/2008/08/nfs-howto-for-centos-5.html
http://rootit.org/2008/07/nfs-shares-on-centos/
http://www.johnandcailin.com/blog/john/scaling-drupal-step-one-dedicated-data-server
http://www.eth0.us/nfs-crash-course
11 August, 2009