There is a new revision of this tutorial available for CentOS 6.3.

Setting Up An NFS Server And Client On CentOS 5.5

Version 1.0
Author: Falko Timme
Follow me on Twitter

This guide explains how to set up an NFS server and an NFS client on CentOS 5.5. NFS stands for Network File System; through NFS, a client can access (read, write) a remote share on an NFS server as if it was on the local hard disk.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I'm using two CentOS systems here:

  • NFS Server:, IP address:
  • NFS Client:, IP address:


2 Installing NFS


On the NFS server we run:

yum install nfs-utils nfs-utils-lib

Then we create the system startup links for the NFS server and start it:

chkconfig --levels 235 nfs on
/etc/init.d/nfs start


On the client we can install NFS as follows (this is actually the same as on the server):

yum install nfs-utils nfs-utils-lib


3 Exporting Directories On The Server


I'd like to make the directories /home and /var/nfs accessible to the client; therefore we must "export" them on the server.

When a client accesses an NFS share, this normally happens as the user nobody. Usually the /home directory isn't owned by nobody (and I don't recommend to change its ownership to nobody!), and because we want to read and write on /home, we tell NFS that accesses should be made as root (if our /home share was read-only, this wouldn't be necessary). The /var/nfs directory doesn't exist, so we can create it and change its ownership; in my tests the user and group nobody both had the ID 99 on both my CentOS test systems (server and client); when I tried to write to /var/nfs from the NFS client, I got a Permission denied error, so I did a chmod 777 /var/nfs so that everyone could write to that directory; writing to /var/nfs from the client worked then, and on the client the files written to /var/nfs appeared to be owned by the user and group nobody, but on the server they were owned by the (nonexistant) user and group with the ID 65534; so I changed ownership of /var/nfs to the user/group 65534 on the server and changed permissions of /var/nfs back to 755, and voilà, the client was allowed to write to /var/nfs:

mkdir /var/nfs
chown 65534:65534 /var/nfs
chmod 755 /var/nfs

Now we must modify /etc/exports where we "export" our NFS shares. We specify /home and /var/nfs as NFS shares and tell NFS to make accesses to /home as root (to learn more about /etc/exports, its format and available options, take a look at

man 5 exports


vi /etc/exports

/home ,sync,no_root_squash,no_subtree_check)

(The no_root_squash option makes that /home will be accessed as root.)

Whenever we modify /etc/exports, we must run

exportfs -a

afterwards to make the changes effective.

Share this page:

3 Comment(s)

Add comment


From: Robert P. J. Day

I've asked this question elsewhere -- can you configure NFS on both the client and server side to use *nothing* but NFSv4 and no earlier versions? If you examine the NFS init script /etc/init.d/nfs, you can see that the mountd invocation accepts options "--no-nfs-version 1", "--no-nfs-version 2" and so on. Can you explicitly deactivate support for all NFS versions other than 4?

From: Phill

I had to tweak the suggested line to get my MacBook OS 10.6.6 to mount the exported folder.  The settings below are as 'relaxed' as I could get it so it could do with more testing to see how much tighter the security can be while still working.

I think the /24 (subnet size) may be importnt in any case though.


From: Joost Ringoot

Nice but:

 If rpcbind is not running, and it isn't on a centos 6 minimal install.

You get these kind of errors:

[[email protected] ]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [FAILED]
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
rpc.nfsd: unable to set any sockets for nfsd
[[email protected] ]# 

 [[email protected] ]# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]
[[email protected] ]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[[email protected] ]#

make it permanent with 

# chkconfig --level 35 rpcbind on