Skip to main content

SUN NFS architecture and operation

Short answer

NFS uses a VFS layer to route local or remote requests; the NFS client sends RPC/XDR requests and the server uses a file handle to access the local file system. It is stateless with idempotent operations, caches data for about 3-30 seconds for files, and supports heterogeneity and mounting.

Explain the architecture and operation of SUN NFS (Network File System) with its features/properties.

SUN NFS (Network File System) is the most widely used distributed file service, developed by Sun Microsystems. It lets a client access remote files as if they were local, over an RPC-based protocol that is independent of the operating system, hardware and network.

Architecture

 Client computer                       Server computer
 +-----------------------------+       +-----------------------------+
 | Application programs        |       |                             |
 |-------- UNIX kernel --------|       |-------- UNIX kernel --------|
 |    Virtual file system      |       |    Virtual file system      |
 |      |              |       |       |       |              |      |
 | +----v-----+  +-----v-----+ |       | +-----v-----+  +-----v----+ |
 | | UNIX     |  | NFS       | |       | | NFS       |  | UNIX     | |
 | | file     |  | client    | |       | | server    |  | file     | |
 | | system   |  |           | |       | |           |  | system   | |
 | +----------+  +-----+-----+ |       | +-----+-----+  +----------+ |
 +---------------------|-------+       +-------|---------------------+
                       |                       |
                       +<---- NFS protocol --->+
                              (RPC over UDP/TCP)
  • Virtual file system (VFS): a layer in the kernel that decides whether a request is for a local file or a remote file and passes it to the UNIX file system or to the NFS client. It keeps a v-node for each open file; the v-node holds an i-node reference for a local file or a file handle for a remote file.
  • NFS client: translates VFS operations into RPC requests to the server.
  • NFS server: receives requests, identifies the file by its file handle (file system id, i-node number, i-node generation number), and calls the local file system.
  • Mount service: a client mounts a remote directory into its local file tree. The server lists the file systems it exports in /etc/exports, and the client records each mounted remote directory in its mount table.
  • Automounter: mounts a remote directory on first use.

Operation

  1. The application issues a system call (for example read).
  2. The VFS finds that the file is remote and calls the NFS client.
  3. The NFS client sends an RPC (lookup, read, write, getattr, create, remove, mkdir, readdir...) over UDP/TCP using XDR encoding.
  4. The NFS server's VFS finds the local file by the file handle, runs the operation on the local file system and returns the result.
  5. The client caches the data (block cache) and attributes. Cache validity is checked by comparing timestamps; a cached entry is trusted for a freshness interval of about 3–30 seconds for files and 30–60 seconds for directories.

Features / properties

  • Access and location transparency through mounting.
  • Stateless server: each request carries all the information needed, so a crashed server restarts without recovery work; operations are idempotent.
  • Heterogeneity: works with any OS that implements the protocol.
  • Caching: read-ahead and delayed write for performance, with approximate (not strict one-copy) consistency.
  • Security: the original version trusted the user id sent in the RPC; later versions use Kerberos.
  • Limited replication and migration support.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Distributed System chapter 2 questions →