NFS, the Network File System : Practical examples

nfs

Introduction

This post gives some commands and tips to ease the tuning of a NFS server. As usual feel free to add your own tips, NFS is quite a big software i am sure you do have some goodies!

 

 

1) Retrieving NFS informations

1.1 Get the NFS version for current NFS mount (on client side)

This is done using the nfsstat command, this command can also gives you a lot of statistics about the NFS server usage.

/usr/sbin/nfsstat -m |grep -Eo 'vers=[[:digit:]]'

 

1.2 Getting the NFS version for current NFS export (on server side)

The command to check the NFS version currently in use is : rpcinfo -p. AFAIK there is no simple command to check the actual NFS version in use, i do have a one-liner for that but it is not very classy… Anyway you can use it if you wish, here it is :

/usr/sbin/rpcinfo  -p localhost |grep -E "nfs\>" |cut -d" " -f 9 |sort -u

Of course awk would also do the job, as well as sed etc… but i do prefer keep it simple.

2) Tune your NFS server

2.1 Forcing a NFS server to use a chosen version

This can be required when trying to access your NFS share using a client that only support a specific version of NFS. In this example we are going to force the use of a NVFv3 server. I personally encounter this when i upgraded my home server to CentOS6.2 which cause my NMT (a PopCorn C200) to be unable to connect to my server anymore…

  • Edit the /etc/sysconfig/nfs configuration file, the lines 5, 6, 27 and 29 are the ones you may changed. in this example they respectively : Line 5 : Force the server NOT to advertise (provide through mountd) the NFSv2 Line 6 : Force the server (through mountd) to actually USE the NFSv3 Line 27 & 29 : Avoid the use of version 2 and 4 through rpc.nfsd
    • Before
    #
    # Define which protocol versions mountd
    # will advertise. The values are "no" or "yes"
    # with yes being the default
    #MOUNTD_NFS_V2="no"
    #MOUNTD_NFS_V3="no"
    #
    #
    # Path to remote quota server. See rquotad(8)
    #RQUOTAD="/usr/sbin/rpc.rquotad"
    # Port rquotad should listen on.
    #RQUOTAD_PORT=32996
    # Optinal options passed to rquotad
    #RPCRQUOTADOPTS=""
    #
    #
    # Optional arguments passed to in-kernel lockd
    #LOCKDARG=
    # TCP port rpc.lockd should listen on.
    #LOCKD_TCPPORT=32999
    # UDP port rpc.lockd should listen on.
    #LOCKD_UDPPORT=32998
    #
    #
    # Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
    # Turn off v2 and v3 protocol support
    #RPCNFSDARGS="-N 2 -N 3"
    # Turn off v4 protocol support
    #RPCNFSDARGS="-N 4"
    # Number of nfs server processes to be started.
    # The default is 8.
    #RPCNFSDCOUNT=8
    # Stop the nfsd module from being pre-loaded
    #NFSD_MODULE="noload"
    # Set V4 grace period in seconds
    #NFSD_V4_GRACE=90
    #
    #
    #
    # Optional arguments passed to rpc.mountd. See rpc.mountd(8)
    #RPCMOUNTDOPTS=""
    # Port rpc.mountd should listen on.
    #MOUNTD_PORT=32997
    #
    #
    # Optional arguments passed to rpc.statd. See rpc.statd(8)
    #STATDARG=""
    # Port rpc.statd should listen on.
    #STATD_PORT=32995
    # Outgoing port statd should used. The default is port
    # is random
    #STATD_OUTGOING_PORT=2020
    # Specify callout program
    #STATD_HA_CALLOUT="/usr/local/bin/foo"
    #
    #
    # Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
    #RPCIDMAPDARGS=""
    #
    # Set to turn on Secure NFS mounts.
    #SECURE_NFS="yes"
    # Optional arguments passed to rpc.gssd. See rpc.gssd(8)
    #RPCGSSDARGS=""
    # Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)
    #RPCSVCGSSDARGS=""
    #
    # To enable RDMA support on the server by setting this to
    # the port the server should listen on
    #RDMA_PORT=20049

    After

    #
    # Define which protocol versions mountd
    # will advertise. The values are "no" or "yes"
    # with yes being the default
    MOUNTD_NFS_V2="no"
    MOUNTD_NFS_V3="yes"
    #
    #
    # Path to remote quota server. See rquotad(8)
    #RQUOTAD="/usr/sbin/rpc.rquotad"
    # Port rquotad should listen on.
    #RQUOTAD_PORT=32996
    # Optinal options passed to rquotad
    #RPCRQUOTADOPTS=""
    #
    #
    # Optional arguments passed to in-kernel lockd
    #LOCKDARG=
    # TCP port rpc.lockd should listen on.
    #LOCKD_TCPPORT=32999
    # UDP port rpc.lockd should listen on.
    #LOCKD_UDPPORT=32998
    #
    #
    # Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
    # Turn off v2 and v3 protocol support
    RPCNFSDARGS="-N 2"
    # Turn off v4 protocol support
    RPCNFSDARGS="-N 4"
    # Number of nfs server processes to be started.
    # The default is 8.
    #RPCNFSDCOUNT=8
    # Stop the nfsd module from being pre-loaded
    #NFSD_MODULE="noload"
    # Set V4 grace period in seconds
    #NFSD_V4_GRACE=90
    #
    #
    #
    # Optional arguments passed to rpc.mountd. See rpc.mountd(8)
    #RPCMOUNTDOPTS=""
    # Port rpc.mountd should listen on.
    #MOUNTD_PORT=32997
    #
    #
    # Optional arguments passed to rpc.statd. See rpc.statd(8)
    #STATDARG=""
    # Port rpc.statd should listen on.
    #STATD_PORT=32995
    # Outgoing port statd should used. The default is port
    # is random
    #STATD_OUTGOING_PORT=2020
    # Specify callout program
    #STATD_HA_CALLOUT="/usr/local/bin/foo"
    #
    #
    # Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
    #RPCIDMAPDARGS=""
    #
    # Set to turn on Secure NFS mounts.
    #SECURE_NFS="yes"
    # Optional arguments passed to rpc.gssd. See rpc.gssd(8)
    #RPCGSSDARGS=""
    # Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)
    #RPCSVCGSSDARGS=""
    #
    # To enable RDMA support on the server by setting this to
    # the port the server should listen on
    #RDMA_PORT=20049
    
    

2.2 Forcing a NFS server to use a static port

The title is actually not true : we are not going to force an NFS server to use a static port but we are going to for RPC to use a static port. This will then allow us to access an NFS share through a firewall for example. This topic has already been covered in the “how-to-get-a-nfs-server-working-with-a-firewall” page, please refer to this page for a detailed guide.

Tagged on: , , , ,

Leave a Reply

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

This site supports SyntaxHighlighter via WP SyntaxHighlighter. It can highlight your code.
How to highlight your code: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag and format it when submitted.