Quick NFS 4 setup on CentOS 5

Based on nfsv4-on-centos-53-and-fedora-11

How to setup NFS4 (and refusing NFS 1, 2 or 3 requests):


On both NFS server and client

  • Install package portmap and nfs-utils
  • Modify /etc/idmapd.conf
  • Stop and remove unnecessary services
  • Start services portmap and rpcidmapd
yum install portmap nfs-utils
 
vi /etc/idmapd.conf
# (...)
# change Nobody-{User,Group} to nfsnobody
# change Domain to <your.fully.qualified.domain.name>
# (...)
 
chkconfig nfslock off
chkconfig rpcgssd off
chkconfig rpcsvcgssd off
service nfslock stop
service rpcgssd stop
service rpcsvcgssd stop
 
chkconfig portmap on
chkconfig rpcidmapd on
service portmap start
service rpcidmapd start


NFS Server

  • Stop nfs service (in case the installation of package started it)
  • Create the root directory for exports (this is specific to NFS v4), eg: /nfs4exports
  • Create a directory you will export on the behalf of the real directory to be exported, eg: /nfs4exports/share1
  • Edit /etc/fstab to bind the nfs share directory to the real directory to be exported
  • Edit /etc/exports to export your directory
  • Mount and bind the directory to export
  • Edit /etc/sysconfig/nfs to activate NFS v4, disable nfs v3 services and <3 compatibility
  • (re)Start and activate NFS service
  • (re)Exports all NFS shared folders
service nfs stop
 
mkdir -p /nfs4exports/share1
 
vi /etc/fstab
# (...)
/somedirectory/youwanttoshare  /nfs4exports/share1    none    bind    0 0
 
mount /nfs4exports/share1
ls /nfs4exports/share1      # Just check
 
vi /etc/fstab
# Replace IP or network by your values
# There is no space between host or IP and export parameters in parenthesis, see the big "Caution" at [[http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/en-US/System_Administration_Guide_/Exporting_NFS_File_Systems-Command_Line_Configuration.html|RHEL4 System Administration Guide - NFS chapter]]
/nfs4exports 192.168.0.0/255.255.255.0(rw,insecure,no_subtree_check,nohide,fsid=0)
/nfs4exports/share 192.168.0.0/255.255.255.0(rw,insecure,no_subtree_check,nohide)
 
vi /etc/sysconfig/nfs
# Add or modify  following settings :
MOUNTD_NFS_V1="no"
MOUNTD_NFS_V2="no"
RPCNFSDARGS="-N 2 -N 3 -U"
 
chkconfig nfs on
service nfs restart
 
exportfs -ar


NFS Client

  • Stop and remove unnecessary services
  • Create the mountpoint directory, eg. /mnt/share1
  • Edit /etc/fstab to add the mount
  • Mount and enjoy
chkconfig nfs off
service nfs stop

mkdir -p /mnt/share1

vi /etc/fstab
# (...)
<NFS_server_host>:/share1   /mnt/share1   nfs4    rsize=8192,wsize=8192,timeo=14,intr,user


howto_nfs4.txt · Last modified: 2010/03/25 04:00 by Alexandre Fouche
Back to top


Alexandre Fouché   |   AlexandreFouche.com   |   yourLinuxSysAdmin.com


Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0