NFSv4 on CentOS 5.3 and Fedora 11

To save the Community the trouble of figuring out how to make this work, here are the steps I used to mount nfsv4 shares on Fedora 11 from a CentOS 5.3 server.

When a line starts with “#” or “as root” that means that you have to execute the command as root.

On the *SERVER* side:

1) as root edit /etc/idmapd.conf:

change Nobody-{User,Group} to nfsnobody
change Domain to <your.fully.qualified.domain.name>

2) create directory with exports

# mkdir /nfs4exports/share

3) as root edit /etc/fstab and add nfs4 exports

/somedirectory/youwanttoshare  /nfs4exports/share    none    bind    0 0

4) activate nfsv4 binds

# mount -a

5) as root edit /etc/exports

Replace 192.168.0.0 below with your IP network.

6) reload exported filesystems

# exportfs -rv

7) stop & disable services

# service nfs stop
# service nfslock stop
# service portmap stop

8) disable unnecessary services

# chkconfig –level 345 nfslock off

9) as root edit /etc/sysconfig/nfs

Use the settings below and leave all other settings as they are.

MOUNTD_NFS_V1=”no”
MOUNTD_NFS_V2=”no”
RPCNFSDARGS=”-N 2 -N 3 -U”

10) start required services

# service portmap start
# service rpcidmapd start
# service nfs start

# chkconfig –level 345 portmap on
# chkconfig –level 345 rpcidmapd on
# chkconfig –level 345 nfs on

On the *CLIENT* side (the Fedora 11 box):

1) as root edit /etc/idmapd.conf:

change Nobody-{User,Group} to nfsnobody
change Domain to <your.fully.qualified.domain.name>

2) create share directories

Off course you can choose the location yourself.

# mkdir /mnt/share

3) as root edit /etc/fstab

Replace <host> below with the hostname or IP address of your CentOS box.

<host>:/share   /mnt/share   nfs4    rsize=8192,wsize=8192,timeo=14,intr,user

4) start required services

# service rpcidmapd start
# chkconfig –level 345 rpcidmapd on

5) mount the bunch

# mount -a

The share will also automatically show up in Nautilus where you can click on it to mount it.

Changelog:
Nov 1, 2009: fixed s/rpcbind/rpcidmapd/ typo in client section based on feedback from Mathiaz and Deadpan110 (thanks!)

6 thoughts on “NFSv4 on CentOS 5.3 and Fedora 11”

  1. Thanks for the article, it was a very handy quick reference for upgrading to NFS v4. One problem that hit me on Centos 5.7, accessing the NFS server via a firewall I also needed to set the NFS tcp_backport (I believe that this may not be needed on NFS v4.1+) and set the server IP address against the host name in /etc/hosts (I was using the loopback address).

    To set the backport under Centos/Red Hat create a .conf file in /etc/modprobe.d/ on the NFS clients (whatever logical name you fancy), and define the backport to use. Then of course ensure that the host/network firewalls are updated to permit that port.

    /etc/modprobe.d/nfs_backport.conf

    options nfs callback_tcpport=2052

    Without that file/entry I was seeing periodic errors in the NFS server log along the lines of:

    servername kernel: nfs4_cb: server “192.168.168.101” not responding, timed out

    Thanks again Patrick.

  2. Once again I’m back here for my quick n easy point of reference :)
    Just a note about my above mentioned MOUNTD_NFS_V3="no".
    I am not exactly sure what that is in the config for as when it is set, the nfs service fails to start even with RPCNFSDARGS="-N 2 -N 3 -U" set. (I suppose I could Google but figured I would leave a comment here to correct my above answer).

  3. @mathiaz …It seems that after a month, this blog owner has not commented back regarding his useful NFSv4 posting.

    I can confirm that ‘rpcidmapd’ is what you will need – it may be a typo as the rest of the post refers correcly.

    Also, MOUNTD_NFS_V3=”no” can be used but IMHO, it would be best to leave that because NFSv4 can then still be mounted as NFSv3 in case of any difficulties.

    Now I have said that… perhaps fallback to NFSv3 would mean that it would not be wise to remove ‘nfslock’ either.

    On a final note for other readers… as this method does not use kerberos with any other types of authentication, you will also need a method to match users and group numbers across the server and clients (as with NFSv3)… for a small network (Like my home network)… I just create our few users on every machine which avoids the use of LDAP/NIS/etc (failing to do this will cause some strange owner and group numbers on the client machines and cause the share to be mainly unusable).

    Other than that… I also use this posting as a point of reference – good work!

  4. hi,

    good work !
    very usefull!

    On the client
    “service rpcbind start”
    I don’t have any rpcbind. Is it rpcidmapd instead?

    On the server why don’t you add
    MOUNTD_NFS_V3=”no” ?

    Thanks,
    Mathiaz

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.