NFS, the Network File System : Concept & generalities

Introduction

As its name strongly suggest, NFS is a file system(!) over a network (local or worldwide). According to the UNIX terminology, an NFS “exported” filesystem can be mounted and once mounted the filesystem may be accessed just as any other local filesystem.

This post tries to give basics and less basics informations to help you using, configuring and understanding NFS.

Please note that i am still working on this post (formatting and organising it to make it as clear as possible)

 

1 NFS basics

NFS like many others network related applications, is built over RPC implemented by rpcbind (rpcbind or portmapper refer to different versions of the same RPC service – Bret Callaghan, 2000, NFS illustrated).

  • On server side:
    NFS
    use the /etc/export file or the exportfs command to specify available filesystem or directories for client mounting.
  • On client side:
    The /etc/fstab file or the mount command should be used to mount an nfs “exported” filesystem.

 

2 NFS v2 & v3

2.1 protocols usage overview

NFS can use up to 5 different daemons as :

  1. rpc.mountd
    The running process that receives the mount request from an NFS client and checks to see if it matches with a currently exported filesystem.
    This daemon uses a Dynamic port. A static port may be define in /etc/sysconfig/nfs (somewhere around line 42). See the “how to get a nfs server working with a firewall” page for more infos.
  2. rpc.nfsd
    The process that implements the user-level part of the NFS service. It works with the Linux kernel to meet the dynamic demands of NFS clients, such as providing additional server threads for NFS clients to utilize.
    This daemon uses a STATIC port.
  3. rpc.lockd
    A daemon that is not necessary with modern kernels. NFS file locking is now done by the kernel. It is included with the nfs-utils package for users utilizing older kernels that do not include this functionality by default.
    This daemon uses a Dynamic port. A static port may be define in /etc/sysconfig/nfs (somewhere around line 19). See the “how to get a nfs server working with a firewall” page for more infos.
  4. rpc.statd
    Implements the Network Status Monitor (NSM) RPC protocol. This provides reboot notification when an NFS server is restarted without being gracefully brought down. (as a side note: this service is not known for its safety! the last version of nfs-utils (1:1.2.3-15.el6) seems to fix some issues…)
    This daemon uses a Dynamic port. A static port may be define in /etc/sysconfig/nfs (somewhere around line 48). See the “how to get a nfs server working with a firewall” page for more infos.
  5. rpc.rquotad
    An RPC server that provides user quota information for remote users.
    This daemon uses a Dynamic port. A static port may be define in /etc/sysconfig/nfs (somewhere around line 12). See the “how to get a nfs server working with a firewall” page for more infos.

 

  • As you did notice in the above list, nfs is making an extensive use of RPC (Remote Procedure Call), That’s why you need to have RPC available on your system (and its related daemons).
  • nfs also needs Portmapper (aka portmap) which use a STATIC port (111) which is, according linux.about.com, a server that converts RPC program numbers into DARPA protocol port numbers. It must be running in order to make RPC calls. Services that use RPC include NFS and NIS.

 

2.2 NFS mounting process

  • On server side, exporting filesystem needs the following :
    1. Start portmap (as mountd uses RPC), the “port mapper“;
    2. Then start mountd, the mounting daemon;
    3. mountd register itself with portmap;
    4. If you have a correct /etc/export file then you should be able able to access your file from the NFSclient

 

  • On the client side, mounting a filesystem follows this process:
    1. The mount program (on client) send a request to remote portmap;
    2. remote portmap (on server) answers to the request with the port number corresponding to mountd daemon;
    3. mount (on client) then contact mountd (on server, using the port number provided by remote port mapper) to process the mount operation;
    4. remote filesystem (exported fs) access is now possible on local system (client).

 

 

3 NFS v4

Unlike its predecessors the version 4 of NFS does NOT requires any RPC and therefore portmapper services : They have been implemented directly within NFS. This is why you do NOT have to mess around with dynamic ports turned into static ports etc…

Configuring a NFSv4 client/server architecture through firewall and other network devices is much simpler than for NFSv3 or v2. The only weak point is that the v4 is not yet widely deployed…

 

 

4 NFSv3 Vs NFSv4

4.1 Features

4.1.1 Overview

nfsv3

  • support for 64-bit file sizes and offsets, to handle files larger than 2 gigabytes (GB)
  • support for asynchronous writes on the server, to improve write performance
  • additional file attributes in many replies, to avoid the need to re-fetch them
  • a READDIRPLUS operation, to get file handles and attributes along with file names when scanning a directory
  • assorted other improvements
  • TCP

nfsv4

  • performance improvements
  • mandates strong security
  • stateful protocol
  • pNFS extension (support for clustered server, included in nfsv4.1 minor update)

 

4.1.2 Details

Functionalities nfsv3 nfsv4
Exports All exports are mounted separately. All exports can be mounted together in a directory tree structure as part of a pseudo-filesystem.
Protocol Numerous protocols for different aspects collected together. MOUNT, LOCK, STATUS…etc. A single protocol with the addition of OPEN and CLOSE for security auditing.
Locking Permanent locks in yet another protocol. Lease based locking in the same protocol.
Security UNIX based. Secure NFS. Mode Bit Locking. Kerberos and ACL based.
Communication One operation per RPC. Multiple operations per RPC. (Improves performance)
I18N All locales must match. UTF-8.
Parallel high bandwidth access None native. (Addition such as MPFS) pNFS.

 

5 Configuration files

5.1 For Server configuration

  • /etc/sysconfig/nfs : Configuration file for NFS server that allows option to be set globally.

 

5.2 For Client configuration

  • /etc/nfsmount.conf : Configuration file for NFS mounts that allows options to be set globally, per server or per mount point.

 

 

Resources

  1. sourceforge nfs pages
  2. interesting debate on using NFS over TCP, although it is “old”
  3. The TCP/IP guide
  4. Excellent inetdoc site (in fench)
  5. CentOS reference page for NFS
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.