Introduction to a ``Network File System'' (NFS)

What was life like before NFS?

Introduction to the Network File System (NFS)

NFS is built on top of:

NFS overview

Two protocols, mount and nfs: ``mount'' protocol establishes initial link between client and server machines

NFS overview

NFS protocols provide a set of RPCs for remote file operations

NFS overview

There was no equivalent to traditional UNIX file table on the server side -- NFS was designed to be stateless on the server side, and each request for data included a full set of arguments rather than assuming persistent state. However, this stateless wasn't all that practical and we soon ended up with caching and file handles.

Each request must provide full set of arguments including a unique file identifier and offset

NFS problems


NFS request

Network File System, FSINFO Call DH:0x75867c04
    Program Version: 3
    V3 Procedure: FSINFO (19)
        length: 12
        hash: 0x75867c04
        type: Linux knfsd (new)
        version: 1
        encoding: 0 0 0
            auth_type: no authentication (0)
            fsid_type: major/minor/inode (0)
            fileid_type: root (0)
        authentication: none
        file system ID: 3,2 (inode 4112441)
            major: 3
            minor: 2
            inode: 4112441
        file ID: root inode

NFS security problems

What are the differences in v2 and v3?

See RFC1813 for a full description of v3. There is a good summary at nfs.sourceforge.net of the differences in v2 and v3:

Starting NFS on Linux

[root@sophie root]# more /etc/exports
/home/exports   monet.cs.fsu.edu(ro,no_root_squash,insecure)

[root@sophie root]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

[root@sophie root]# /etc/init.d/iptables stop
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]

Starting NFS on Linux

On the client side:

mount sophie:/etc/exports /mnt-tmp

Starting NFS on Linux

What is actually done when on a Linux machine when you run /etc/init.d/nfs start?

Here's what to look for:

portmap    # maybe, usually not these days
exportfs   # /etc/exports

Starting NFS on Solaris

shareall   # /etc/dfs/dfstab, not /etc/dfs/sharetab

NFS Security

Tuning NFS

NFS probably will work just fine "out of the box", but if you feel the urge to tinker, look at perhaps:

Tuning NFS

/usr/sbin/nfsstat -s

Server rpc stats:
calls      badcalls   badauth    badclnt    xdrcall
28         0          0          0          0       
Server nfs v3:
null       getattr    setattr    lookup     access     readlink   
2       7% 10     35% 0       0% 2       7% 3      10% 0       0% 
read       write      create     mkdir      symlink    mknod      
8      28% 0       0% 0       0% 0       0% 0       0% 0       0% 
remove     rmdir      rename     link       readdir    readdirplus
0       0% 0       0% 0       0% 0       0% 0       0% 1       3% 
fsstat     fsinfo     pathconf   commit     
0       0% 2       7% 0       0% 0       0% 

Tuning NFS clientside

Tuning with mount command:

Tuning NFS on Linux

On a Linux server, you can try sysctl:


Original implementations were buggy, and some required reboots to straighten out problems.

For most production environments, the reasons for automounting are less of an issue from server-to-server since this is not done a great deal in practice and almost never to random hosts as auto-mounting assumes; for server-to-client, this would be only a benefit where a number of distinct NFS servers needed to be accessed on an irregular basis by a given client — not all common these days. A better solution for this problem is likely sshfs

Beyond NFS v3

NFS v4 (RFC3530)

Variations on NFS

AFS — Andrew File System

More references

A very good reference for NFS operations can be found http://nfs.sourceforge.net/nfs-howto/