# NFS

---

# NFS

_Peios Kernel / Administration / System administration / NFS_

> Reference for NFS.

<a id="rst-nfs"></a>

- [NFS Client](</kernel/administration/admin-guide/nfs/nfs-client.md>)
- [Mounting the root filesystem via NFS (nfsroot)](</kernel/administration/admin-guide/nfs/nfsroot.md>)
- [Setting up NFS/RDMA](</kernel/administration/admin-guide/nfs/nfs-rdma.md>)
- [Administrative interfaces for nfsd](</kernel/administration/admin-guide/nfs/nfsd-admin-interfaces.md>)
- [NFS ID Mapper](</kernel/administration/admin-guide/nfs/nfs-idmapper.md>)
- [pNFS block layout server user guide](</kernel/administration/admin-guide/nfs/pnfs-block-server.md>)
- [pNFS SCSI layout server user guide](</kernel/administration/admin-guide/nfs/pnfs-scsi-server.md>)

---

# NFS Client

_Peios Kernel / Administration / System administration / NFS_

> The NFS version 2 protocol was first documented in RFC1094 (March 1989). Since then two more major releases of NFS have been published, with NFSv3 being documented in RFC1813 (June 1995), and NFSv4 in RFC3530 (April 2003).

<a id="rst-nfs-client"></a>

<a id="rst-the-nfs-client"></a>

## The NFS client

The NFS version 2 protocol was first documented in RFC1094 (March 1989). Since then two more major releases of NFS have been published, with NFSv3 being documented in RFC1813 (June 1995), and NFSv4 in RFC3530 (April 2003).

The Linux NFS client currently supports all the above published versions, and work is in progress on adding support for minor version 1 of the NFSv4 protocol.

The purpose of this document is to provide information on some of the special features of the NFS client that can be configured by system administrators.

<a id="rst-the-nfs4-unique-id-parameter"></a>

## The nfs4_unique_id parameter

NFSv4 requires clients to identify themselves to servers with a unique string.  File open and lock state shared between one client and one server is associated with this identity.  To support robust NFSv4 state recovery and transparent state migration, this identity string must not change across client reboots.

Without any other intervention, the Linux client uses a string that contains the local system's node name.  System administrators, however, often do not take care to ensure that node names are fully qualified and do not change over the lifetime of a client system.  Node names can have other administrative requirements that require particular behavior that does not work well as part of an nfs_client_id4 string.

The nfs.nfs4_unique_id boot parameter specifies a unique string that can be used together with  a system's node name when an NFS client identifies itself to a server.  Thus, if the system's node name is not unique, its nfs.nfs4_unique_id can help prevent collisions with other clients.

The nfs.nfs4_unique_id string is typically a UUID, though it can contain anything that is believed to be unique across all NFS clients.  An nfs4_unique_id string should be chosen when a client system is installed, just as a system's root file system gets a fresh UUID in its label at install time.

The string should remain fixed for the lifetime of the client.  It can be changed safely if care is taken that the client shuts down cleanly and all outstanding NFSv4 state has expired, to prevent loss of NFSv4 state.

This string can be stored in an NFS client's grub.conf, or it can be provided via a net boot facility such as PXE.  It may also be specified as an nfs.ko module parameter.

This uniquifier string will be the same for all NFS clients running in containers unless it is overridden by a value written to /sys/fs/nfs/net/nfs_client/identifier which will be local to the network namespace of the process which writes.

<a id="rst-the-dns-resolver"></a>

## The DNS resolver

NFSv4 allows for one server to refer the NFS client to data that has been migrated onto another server by means of the special "fs_locations" attribute. See [RFC3530 Section 6: Filesystem Migration and Replication](<https://tools.ietf.org/html/rfc3530#section-6>) and [Implementation Guide for Referrals in NFSv4](<https://tools.ietf.org/html/draft-ietf-nfsv4-referrals-00>).

<a id="rst-rfc3530-section-6-filesystem-migration-and-replication"></a>



<a id="rst-implementation-guide-for-referrals-in-nfsv4"></a>



The fs_locations information can take the form of either an ip address and a path, or a DNS hostname and a path. The latter requires the NFS client to do a DNS lookup in order to mount the new volume, and hence the need for an upcall to allow userland to provide this service.

Assuming that the user has the 'rpc_pipefs' filesystem mounted in the usual /var/lib/nfs/rpc_pipefs, the upcall consists of the following steps:

> 1. The process checks the dns_resolve cache to see if it contains a valid entry. If so, it returns that entry and exits.
>
> 2. If no valid entry exists, the helper script '/sbin/nfs_cache_getent' (may be changed using the 'nfs.cache_getent' kernel boot parameter) is run, with two arguments: - the cache name, "dns_resolve" - the hostname to resolve
>
> 3. After looking up the corresponding ip address, the helper script writes the result into the rpc_pipefs pseudo-file '/var/lib/nfs/rpc_pipefs/cache/dns_resolve/channel' in the following (text) format:
>
>    > "&lt;ip address&gt; &lt;hostname&gt; &lt;ttl&gt;n"
>
>    Where &lt;ip address&gt; is in the usual IPv4 (123.456.78.90) or IPv6 (ffee:ddcc:bbaa:9988:7766:5544:3322:1100, ffee::1100, ...) format. &lt;hostname&gt; is identical to the second argument of the helper script, and &lt;ttl&gt; is the 'time to live' of this cache entry (in units of seconds).
>
>    > [!NOTE]
>    >
>    > If &lt;ip address&gt; is invalid, say the string "0", then a negative entry is created, which will cause the kernel to treat the hostname as having no valid DNS translation.

<a id="rst-a-basic-sample-sbin-nfs-cache-getent"></a>

## A basic sample /sbin/nfs_cache_getent



```sh
#!/bin/bash
#
ttl=600
#
cut=/usr/bin/cut
getent=/usr/bin/getent
rpc_pipefs=/var/lib/nfs/rpc_pipefs
#
die()
{
    echo "Usage: $0 cache_name entry_name"
    exit 1
}

[ $# -lt 2 ] && die
cachename="$1"
cache_path=${rpc_pipefs}/cache/${cachename}/channel

case "${cachename}" in
    dns_resolve)
        name="$2"
        result="$(${getent} hosts ${name} | ${cut} -f1 -d\ )"
        [ -z "${result}" ] && result="0"
        ;;
    *)
        die
        ;;
esac
echo "${result} ${name} ${ttl}" >${cache_path}
```

---

# NFS ID Mapper

_Peios Kernel / Administration / System administration / NFS_

> Id mapper is used by NFS to translate user and group ids into names, and to translate user and group names into ids. Part of this translation involves performing an upcall to userspace to request the information. There are two ways NFS…

<a id="rst-nfs-id-mapper"></a>

Id mapper is used by NFS to translate user and group ids into names, and to translate user and group names into ids.  Part of this translation involves performing an upcall to userspace to request the information.  There are two ways NFS could obtain this information: placing a call to /sbin/request-key or by placing a call to the rpc.idmap daemon.

NFS will attempt to call /sbin/request-key first.  If this succeeds, the result will be cached using the generic request-key cache.  This call should only fail if /etc/request-key.conf is not configured for the id_resolver key type, see the "Configuring" section below if you wish to use the request-key method.

If the call to /sbin/request-key fails (if /etc/request-key.conf is not configured with the id_resolver key type), then the idmapper will ask the legacy rpc.idmap daemon for the id mapping.  This result will be stored in a custom NFS idmap cache.

<a id="rst-configuring"></a>

## Configuring

The file /etc/request-key.conf will need to be modified so /sbin/request-key can direct the upcall.  The following line should be added:

`#OP   TYPE    DESCRIPTION     CALLOUT INFO    PROGRAM ARG1 ARG2 ARG3 ...` `#======       ======= =============== =============== ===============================` `create        id_resolver     *       *               /usr/sbin/nfs.idmap %k %d 600`

This will direct all id_resolver requests to the program /usr/sbin/nfs.idmap. The last parameter, 600, defines how many seconds into the future the key will expire.  This parameter is optional for /usr/sbin/nfs.idmap.  When the timeout is not specified, nfs.idmap will default to 600 seconds.

id mapper uses for key descriptions:



```text
  uid:  Find the UID for the given user
  gid:  Find the GID for the given group
 user:  Find the user  name for the given UID
group:  Find the group name for the given GID
```

You can handle any of these individually, rather than using the generic upcall program.  If you would like to use your own program for a uid lookup then you would edit your request-key.conf so it look similar to this:

`#OP   TYPE    DESCRIPTION     CALLOUT INFO    PROGRAM ARG1 ARG2 ARG3 ...` `#======       ======= =============== =============== ===============================` `create        id_resolver     uid:*   *               /some/other/program %k %d 600` `create        id_resolver     *       *               /usr/sbin/nfs.idmap %k %d 600`

Notice that the new line was added above the line for the generic program. request-key will find the first matching line and corresponding program.  In this case, /some/other/program will handle all uid lookups and /usr/sbin/nfs.idmap will handle gid, user, and group lookups.

See [Documentation/security/keys/request-key.rst](/kernel/internals/security/keys/request-key.md) for more information about the request-key function.

<a id="rst-nfs-idmap"></a>

## nfs.idmap

nfs.idmap is designed to be called by request-key, and should not be run "by hand".  This program takes two arguments, a serialized key and a key description.  The serialized key is first converted into a key_serial_t, and then passed as an argument to keyctl_instantiate (both are part of keyutils.h).

The actual lookups are performed by functions found in nfsidmap.h.  nfs.idmap determines the correct function to call by looking at the first part of the description string.  For example, a uid lookup description will appear as "uid:user@domain".

nfs.idmap will return 0 if the key was instantiated, and non-zero otherwise.

---

# Setting up NFS/RDMA

_Peios Kernel / Administration / System administration / NFS_

> This document describes how to install and setup the Linux NFS/RDMA client and server software.

<a id="rst-setting-up-nfs-rdma"></a>

**Author:** NetApp and Open Grid Computing (May 29, 2008)

> [!WARNING]
>
> This document is probably obsolete.

<a id="rst-overview"></a>

## Overview

This document describes how to install and setup the Linux NFS/RDMA client and server software.

The NFS/RDMA client was first included in Linux 2.6.24. The NFS/RDMA server was first included in the following release, Linux 2.6.25.

In our testing, we have obtained excellent performance results (full 10Gbit wire bandwidth at minimal client CPU) under many workloads. The code passes the full Connectathon test suite and operates over both Infiniband and iWARP RDMA adapters.

<a id="rst-getting-help"></a>

## Getting Help

If you get stuck, you can ask questions on the [nfs-rdma-devel@lists.sourceforge.net](<mailto:nfs-rdma-devel@lists.sourceforge.net>) mailing list.

<a id="rst-installation"></a>

## Installation

These instructions are a step by step guide to building a machine for use with NFS/RDMA.

- Install an RDMA device

  Any device supported by the drivers in drivers/infiniband/hw is acceptable.

  Testing has been performed using several Mellanox-based IB cards, the Ammasso AMS1100 iWARP adapter, and the Chelsio cxgb3 iWARP adapter.

- Install a Linux distribution and tools

  The first kernel release to contain both the NFS/RDMA client and server was Linux 2.6.25  Therefore, a distribution compatible with this and subsequent Linux kernel release should be installed.

  The procedures described in this document have been tested with distributions from Red Hat's Fedora Project ([http://fedora.redhat.com/](<http://fedora.redhat.com/>)).

- Install nfs-utils-1.1.2 or greater on the client

  An NFS/RDMA mount point can be obtained by using the mount.nfs command in nfs-utils-1.1.2 or greater (nfs-utils-1.1.1 was the first nfs-utils version with support for NFS/RDMA mounts, but for various reasons we recommend using nfs-utils-1.1.2 or greater). To see which version of mount.nfs you are using, type:



  ```sh
  $ /sbin/mount.nfs -V
  ```

  If the version is less than 1.1.2 or the command does not exist, you should install the latest version of nfs-utils.

  Download the latest package from: [https://www.kernel.org/pub/linux/utils/nfs](<https://www.kernel.org/pub/linux/utils/nfs>)

  Uncompress the package and follow the installation instructions.

  If you will not need the idmapper and gssd executables (you do not need these to create an NFS/RDMA enabled mount command), the installation process can be simplified by disabling these features when running configure:



  ```sh
  $ ./configure --disable-gss --disable-nfsv4
  ```

  To build nfs-utils you will need the tcp_wrappers package installed. For more information on this see the package's README and INSTALL files.

  After building the nfs-utils package, there will be a mount.nfs binary in the utils/mount directory. This binary can be used to initiate NFS v2, v3, or v4 mounts. To initiate a v4 mount, the binary must be called mount.nfs4.  The standard technique is to create a symlink called mount.nfs4 to mount.nfs.

  This mount.nfs binary should be installed at /sbin/mount.nfs as follows:



  ```sh
  $ sudo cp utils/mount/mount.nfs /sbin/mount.nfs
  ```

  In this location, mount.nfs will be invoked automatically for NFS mounts by the system mount command.

  > > [!NOTE]
  > >
  > > mount.nfs and therefore nfs-utils-1.1.2 or greater is only needed on the NFS client machine. You do not need this specific version of nfs-utils on the server. Furthermore, only the mount.nfs command from nfs-utils-1.1.2 is needed on the client.

- Install a Linux kernel with NFS/RDMA

  The NFS/RDMA client and server are both included in the mainline Linux kernel version 2.6.25 and later. This and other versions of the Linux kernel can be found at: [https://www.kernel.org/pub/linux/kernel/](<https://www.kernel.org/pub/linux/kernel/>)

  Download the sources and place them in an appropriate location.

- Configure the RDMA stack

  Make sure your kernel configuration has RDMA support enabled. Under Device Drivers -&gt; InfiniBand support, update the kernel configuration to enable InfiniBand support \[NOTE: the option name is misleading. Enabling InfiniBand support is required for all RDMA devices (IB, iWARP, etc.)\].

  Enable the appropriate IB HCA support (mlx4, mthca, ehca, ipath, etc.) or iWARP adapter support (amso, cxgb3, etc.).

  If you are using InfiniBand, be sure to enable IP-over-InfiniBand support.

- Configure the NFS client and server

  Your kernel configuration must also have NFS file system support and/or NFS server support enabled. These and other NFS related configuration options can be found under File Systems -&gt; Network File Systems.

- Build, install, reboot

  The NFS/RDMA code will be enabled automatically if NFS and RDMA are turned on. The NFS/RDMA client and server are configured via the hidden SUNRPC_XPRT_RDMA config option that depends on SUNRPC and INFINIBAND. The value of SUNRPC_XPRT_RDMA will be:

  > 1. N if either SUNRPC or INFINIBAND are N, in this case the NFS/RDMA client and server will not be built
  >
  > 2. M if both SUNRPC and INFINIBAND are on (M or Y) and at least one is M, in this case the NFS/RDMA client and server will be built as modules
  >
  > 3. Y if both SUNRPC and INFINIBAND are Y, in this case the NFS/RDMA client and server will be built into the kernel

  Therefore, if you have followed the steps above and turned no NFS and RDMA, the NFS/RDMA client and server will be built.

  Build a new kernel, install it, boot it.

<a id="rst-check-rdma-and-nfs-setup"></a>

## Check RDMA and NFS Setup

Before configuring the NFS/RDMA software, it is a good idea to test your new kernel to ensure that the kernel is working correctly. In particular, it is a good idea to verify that the RDMA stack is functioning as expected and standard NFS over TCP/IP and/or UDP/IP is working properly.

- Check RDMA Setup

  If you built the RDMA components as modules, load them at this time. For example, if you are using a Mellanox Tavor/Sinai/Arbel card:



  ```sh
  $ modprobe ib_mthca
  $ modprobe ib_ipoib
  ```

  If you are using InfiniBand, make sure there is a Subnet Manager (SM) running on the network. If your IB switch has an embedded SM, you can use it. Otherwise, you will need to run an SM, such as OpenSM, on one of your end nodes.

  If an SM is running on your network, you should see the following:



  ```sh
  $ cat /sys/class/infiniband/driverX/ports/1/state
  4: ACTIVE
  ```

  where driverX is mthca0, ipath5, ehca3, etc.

  To further test the InfiniBand software stack, use IPoIB (this assumes you have two IB hosts named host1 and host2):



  ```sh
  host1$ ip link set dev ib0 up
  host1$ ip address add dev ib0 a.b.c.x
  host2$ ip link set dev ib0 up
  host2$ ip address add dev ib0 a.b.c.y
  host1$ ping a.b.c.y
  host2$ ping a.b.c.x
  ```

  For other device types, follow the appropriate procedures.

- Check NFS Setup

  For the NFS components enabled above (client and/or server), test their functionality over standard Ethernet using TCP/IP or UDP/IP.

<a id="rst-nfs-rdma-setup"></a>

## NFS/RDMA Setup

We recommend that you use two machines, one to act as the client and one to act as the server.

<a id="rst-one-time-configuration"></a>

### One time configuration:

- On the server system, configure the /etc/exports file and start the NFS/RDMA server.

  Exports entries with the following formats have been tested:



  ```text
  /vol0   192.168.0.47(fsid=0,rw,async,insecure,no_root_squash)
  /vol0   192.168.0.0/255.255.255.0(fsid=0,rw,async,insecure,no_root_squash)
  ```

  The IP address(es) is(are) the client's IPoIB address for an InfiniBand HCA or the client's iWARP address(es) for an RNIC.

  > [!NOTE]
  >
  > The "insecure" option must be used because the NFS/RDMA client does not use a reserved port.

<a id="rst-each-time-a-machine-boots"></a>

### Each time a machine boots:

- Load and configure the RDMA drivers

  For InfiniBand using a Mellanox adapter:



  ```sh
  $ modprobe ib_mthca
  $ modprobe ib_ipoib
  $ ip li set dev ib0 up
  $ ip addr add dev ib0 a.b.c.d
  ```

  > [!NOTE]
  >
  > Please use unique addresses for the client and server\!

- Start the NFS server

  If the NFS/RDMA server was built as a module (CONFIG_SUNRPC_XPRT_RDMA=m in kernel config), load the RDMA transport module:



  ```sh
  $ modprobe svcrdma
  ```

  Regardless of how the server was built (module or built-in), start the server:



  ```sh
  $ /etc/init.d/nfs start
  ```

  or



  ```sh
  $ service nfs start
  ```

  Instruct the server to listen on the RDMA transport:



  ```sh
  $ echo rdma 20049 > /proc/fs/nfsd/portlist
  ```

- On the client system

  If the NFS/RDMA client was built as a module (CONFIG_SUNRPC_XPRT_RDMA=m in kernel config), load the RDMA client module:



  ```sh
  $ modprobe xprtrdma.ko
  ```

  Regardless of how the client was built (module or built-in), use this command to mount the NFS/RDMA server:



  ```sh
  $ mount -o rdma,port=20049 <IPoIB-server-name-or-address>:/<export> /mnt
  ```

  To verify that the mount is using RDMA, run "cat /proc/mounts" and check the "proto" field for the given mount.

  Congratulations\! You're using NFS/RDMA\!

---

# Administrative interfaces for nfsd

_Peios Kernel / Administration / System administration / NFS_

> Note that normally these interfaces are used only by the utilities in nfs-utils.

<a id="rst-administrative-interfaces-for-nfsd"></a>

Note that normally these interfaces are used only by the utilities in nfs-utils.

nfsd is controlled mainly by pseudofiles under the "nfsd" filesystem, which is normally mounted at /proc/fs/nfsd/.

The server is always started by the first write of a nonzero value to nfsd/threads.

Before doing that, NFSD can be told which sockets to listen on by writing to nfsd/portlist; that write may be:

> - an ascii-encoded file descriptor, which should refer to a bound (and listening, for tcp) socket, or
>
> - "transportname port", where transportname is currently either "udp", "tcp", or "rdma".

If nfsd is started without doing any of these, then it will create one udp and one tcp listener at port 2049 (see nfsd_init_socks).

On startup, nfsd and lockd grace periods start. nfsd is shut down by a write of 0 to nfsd/threads.  All locks and state are thrown away at that point.

Between startup and shutdown, the number of threads may be adjusted up or down by additional writes to nfsd/threads or by writes to nfsd/pool_threads.

For more detail about files under nfsd/ and what they control, see fs/nfsd/nfsctl.c; most of them have detailed comments.

<a id="rst-implementation-notes"></a>

## Implementation notes

Note that the rpc server requires the caller to serialize addition and removal of listening sockets, and startup and shutdown of the server. For nfsd this is done using nfsd_mutex.

---

# Mounting the root filesystem via NFS (nfsroot)

_Peios Kernel / Administration / System administration / NFS_

> In order to use a diskless system, such as an X-terminal or printer server for example, it is necessary for the root filesystem to be present on a non-disk device. This may be an initramfs (see…

> **Peios:** User namespaces and Unix ID mappings do not create native privileges or determine KACS descriptor identity. Mount authorization uses the native privilege/descriptor rules; the descriptor-only new-filesystem allowlist is `tmpfs`, `proc` and `stratafs`. See [Peios kernel behaviour](</kernel/introduction/peios-behaviour.md>).


<a id="rst-mounting-the-root-filesystem-via-nfs-nfsroot"></a>

**Authors:** Written 1996 by Gero Kuhlmann &lt;[gero@gkminix.han.de](<mailto:gero@gkminix.han.de>)&gt;

Updated 1997 by Martin Mares &lt;[mj@atrey.karlin.mff.cuni.cz](<mailto:mj@atrey.karlin.mff.cuni.cz>)&gt;

Updated 2006 by Nico Schottelius &lt;[nico-kernel-nfsroot@schottelius.org](<mailto:nico-kernel-nfsroot@schottelius.org>)&gt;

Updated 2006 by Horms &lt;[horms@verge.net.au](<mailto:horms@verge.net.au>)&gt;

Updated 2018 by Chris Novakovic &lt;[chris@chrisn.me.uk](<mailto:chris@chrisn.me.uk>)&gt;

In order to use a diskless system, such as an X-terminal or printer server for example, it is necessary for the root filesystem to be present on a non-disk device. This may be an initramfs (see [Documentation/filesystems/ramfs-rootfs-initramfs.rst](/kernel/internals/filesystems/ramfs-rootfs-initramfs.md)), a ramdisk (see [Documentation/admin-guide/initrd.rst](/kernel/administration/admin-guide/boot/initrd.md)) or a filesystem mounted via NFS. The following text describes on how to use NFS for the root filesystem. For the rest of this text 'client' means the diskless system, and 'server' means the NFS server.

<a id="rst-enabling-nfsroot-capabilities"></a>

## Enabling nfsroot capabilities

In order to use nfsroot, NFS client support needs to be selected as built-in during configuration. Once this has been selected, the nfsroot option will become available, which should also be selected.

In the networking options, kernel level autoconfiguration can be selected, along with the types of autoconfiguration to support. Selecting all of DHCP, BOOTP and RARP is safe.

<a id="rst-kernel-command-line"></a>

## Kernel command line

When the kernel has been loaded by a boot loader (see below) it needs to be told what root fs device to use. And in the case of nfsroot, where to find both the server and the name of the directory on the server to mount as root. This can be established using the following kernel command line parameters:

- **root=/dev/nfs**

  This is necessary to enable the pseudo-NFS-device. Note that it's not a real device but just a synonym to tell the kernel to use NFS instead of a real device.

- **nfsroot=\[&lt;server-ip&gt;:\]&lt;root-dir&gt;\[,&lt;nfs-options&gt;\]**

  If the `` nfsroot' parameter is NOT given on the command line, the default ` ``"/tftpboot/%s"\`\` will be used.

  - **&lt;server-ip&gt;   Specifies the IP address of the NFS server.**

    The default address is determined by the ip parameter (see below). This parameter allows the use of different servers for IP autoconfiguration and NFS.

  - **&lt;root-dir&gt;    Name of the directory on the server to mount as root.**

    If there is a "%s" token in the string, it will be replaced by the ASCII-representation of the client's IP address.

  - **&lt;nfs-options&gt; Standard NFS options. All options are separated by commas.**

    The following defaults are used:



    ```text
    port            = as given by server portmap daemon
    rsize           = 4096
    wsize           = 4096
    timeo           = 7
    retrans         = 3
    acregmin        = 3
    acregmax        = 60
    acdirmin        = 30
    acdirmax        = 60
    flags           = hard, nointr, noposix, cto, ac
    ```

- **ip=&lt;client-ip&gt;:&lt;server-ip&gt;:&lt;gw-ip&gt;:&lt;netmask&gt;:&lt;hostname&gt;:&lt;device&gt;:&lt;autoconf&gt;:&lt;dns0-ip&gt;:&lt;dns1-ip&gt;:&lt;ntp0-ip&gt;**

  This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It was originally called nfsaddrs, but now the boot-time IP configuration works independently of NFS, so it was renamed to ip and the old name remained as an alias for compatibility reasons.

  If this parameter is missing from the kernel command line, all fields are assumed to be empty, and the defaults mentioned below apply. In general this means that the kernel tries to configure everything using autoconfiguration.

  The &lt;autoconf&gt; parameter can appear alone as the value to the ip parameter (without all the ':' characters before).  If the value is "ip=off" or "ip=none", no autoconfiguration will take place, otherwise autoconfiguration will take place.  The most common way to use this is "ip=dhcp".

  - **&lt;client-ip&gt;   IP address of the client.**

    Default:  Determined using autoconfiguration.

  - **&lt;server-ip&gt;   IP address of the NFS server.**

    If RARP is used to determine the client address and this parameter is NOT empty only replies from the specified server are accepted.

    Only required for NFS root. That is autoconfiguration will not be triggered if it is missing and NFS root is not in operation.

    Value is exported to /proc/net/pnp with the prefix "bootserver " (see below).

    Default: Determined using autoconfiguration. The address of the autoconfiguration server is used.

  - **&lt;gw-ip&gt;       IP address of a gateway if the server is on a different subnet.**

    Default: Determined using autoconfiguration.

  - **&lt;netmask&gt;     Netmask for local network interface.**

    If unspecified the netmask is derived from the client IP address assuming classful addressing.

    Default:  Determined using autoconfiguration.

  - **&lt;hostname&gt;    Name of the client.**

    If a '.' character is present, anything before the first '.' is used as the client's hostname, and anything after it is used as its NIS domain name. May be supplied by autoconfiguration, but its absence will not trigger autoconfiguration. If specified and DHCP is used, the user-provided hostname (and NIS domain name, if present) will be carried in the DHCP request; this may cause a DNS record to be created or updated for the client.

    Default: Client IP address is used in ASCII notation.

  - **&lt;device&gt;      Name of network device to use.**

    Default: If the host only has one device, it is used. Otherwise the device is determined using autoconfiguration. This is done by sending autoconfiguration requests out of all devices, and using the device that received the first reply.

  - **&lt;autoconf&gt;    Method to use for autoconfiguration.**

    In the case of options which specify multiple autoconfiguration protocols, requests are sent using all protocols, and the first one to reply is used.

    Only autoconfiguration protocols that have been compiled into the kernel will be used, regardless of the value of this option:



    ```text
    off or none: don't use autoconfiguration
                  (do static IP assignment instead)
    on or any:   use any protocol available in the kernel
                 (default)
    dhcp:        use DHCP
    bootp:       use BOOTP
    rarp:        use RARP
    both:        use both BOOTP and RARP but not DHCP
                 (old option kept for backwards compatibility)
    ```

    if dhcp is used, the client identifier can be used by following format "ip=dhcp,client-id-type,client-id-value"

    Default: any

  - **&lt;dns0-ip&gt;     IP address of primary nameserver.**

    Value is exported to /proc/net/pnp with the prefix "nameserver " (see below).

    Default: None if not using autoconfiguration; determined automatically if using autoconfiguration.

  - **&lt;dns1-ip&gt;     IP address of secondary nameserver.**

    See &lt;dns0-ip&gt;.

  - **&lt;ntp0-ip&gt;     IP address of a Network Time Protocol (NTP) server.**

    Value is exported to /proc/net/ipconfig/ntp_servers, but is otherwise unused (see below).

    Default: None if not using autoconfiguration; determined automatically if using autoconfiguration.

  After configuration (whether manual or automatic) is complete, two files are created in the following format; lines are omitted if their respective value is empty following configuration:

  - /proc/net/pnp:

    > \#PROTO: &lt;DHCP\|BOOTP\|RARP\|MANUAL&gt;        (depending on configuration method) domain &lt;dns-domain&gt;                     (if autoconfigured, the DNS domain) nameserver &lt;dns0-ip&gt;                    (primary name server IP) nameserver &lt;dns1-ip&gt;                    (secondary name server IP) nameserver &lt;dns2-ip&gt;                    (tertiary name server IP) bootserver &lt;server-ip&gt;                  (NFS server IP)

  - /proc/net/ipconfig/ntp_servers:

    > &lt;ntp0-ip&gt;                               (NTP server IP) &lt;ntp1-ip&gt;                               (NTP server IP) &lt;ntp2-ip&gt;                               (NTP server IP)

  &lt;dns-domain&gt; and &lt;dns2-ip&gt; (in /proc/net/pnp) and &lt;ntp1-ip&gt; and &lt;ntp2-ip&gt; (in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration; they cannot be specified as part of the "ip=" kernel command line parameter.

  Because the "domain" and "nameserver" options are recognised by DNS resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems that use an NFS root filesystem.

  Note that the kernel will not synchronise the system time with any NTP servers it discovers; this is the responsibility of a user space process (e.g. an initrd/initramfs script that passes the IP addresses listed in /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real root filesystem if it is on NFS).

- **nfsrootdebug**

  This parameter enables debugging messages to appear in the kernel log at boot time so that administrators can verify that the correct NFS mount options, server address, and root path are passed to the NFS client.

- **rdinit=&lt;executable file&gt;**

  To specify which file contains the program that starts system initialization, administrators can use this command line parameter. The default value of this parameter is "/init".  If the specified file exists and the kernel can execute it, root filesystem related kernel command line parameters, including 'nfsroot=', are ignored.

  A description of the process of mounting the root file system can be found in [Documentation/driver-api/early-userspace/early_userspace_support.rst](/kernel/hardware/driver-api/early-userspace/early-userspace-support.md)

<a id="rst-boot-loader"></a>

## Boot Loader

To get the kernel into memory different approaches can be used. They depend on various facilities being available:

- Booting from a floppy using syslinux

  > When building kernels, an easy way to create a boot floppy that uses syslinux is to use the zdisk or bzdisk make targets which use zimage and bzimage images respectively. Both targets accept the FDARGS parameter which can be used to set the kernel command line.
  >
  > e.g:
  >
  >
  >
  > ```text
  > make bzdisk FDARGS="root=/dev/nfs"
  > ```
  >
  > Note that the user running this command will need to have access to the floppy drive device, /dev/fd0
  >
  > For more information on syslinux, including how to create bootdisks for prebuilt kernels, see [https://syslinux.zytor.com/](<https://syslinux.zytor.com/>)
  >
  > > [!NOTE]
  > >
  > > Previously it was possible to write a kernel directly to a floppy using dd, configure the boot device using rdev, and boot using the resulting floppy. Linux no longer supports this method of booting.

- Booting from a cdrom using isolinux

  > When building kernels, an easy way to create a bootable cdrom that uses isolinux is to use the isoimage target which uses a bzimage image. Like zdisk and bzdisk, this target accepts the FDARGS parameter which can be used to set the kernel command line.
  >
  > e.g:
  >
  >
  >
  > ```text
  > make isoimage FDARGS="root=/dev/nfs"
  > ```
  >
  > The resulting iso image will be arch/&lt;ARCH&gt;/boot/image.iso This can be written to a cdrom using a variety of tools including cdrecord.
  >
  > e.g:
  >
  >
  >
  > ```text
  > cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso
  > ```
  >
  > For more information on isolinux, including how to create bootdisks for prebuilt kernels, see [https://syslinux.zytor.com/](<https://syslinux.zytor.com/>)

- Using LILO

  > When using LILO all the necessary command line parameters may be specified using the 'append=' directive in the LILO configuration file.
  >
  > However, to use the 'root=' directive you also need to create a dummy root device, which may be removed after LILO is run.
  >
  > e.g:
  >
  >
  >
  > ```text
  > mknod /dev/boot255 c 0 255
  > ```
  >
  > For information on configuring LILO, please refer to its documentation.

- Using GRUB

  > When using GRUB, kernel parameter are simply appended after the kernel specification: kernel &lt;kernel&gt; &lt;parameters&gt;

- Using loadlin

  > loadlin may be used to boot Linux from a DOS command prompt without requiring a local hard disk to mount as root. This has not been thoroughly tested by the authors of this document, but in general it should be possible configure the kernel command line similarly to the configuration of LILO.
  >
  > Please refer to the loadlin documentation for further information.

- Using a boot ROM

  > This is probably the most elegant way of booting a diskless client. With a boot ROM the kernel is loaded using the TFTP protocol. The authors of this document are not aware of any no commercial boot ROMs that support booting Linux over the network. However, there are two free implementations of a boot ROM, netboot-nfs and etherboot, both of which are available on sunsite.unc.edu, and both of which contain everything you need to boot a diskless Linux client.

- Using pxelinux

  > Pxelinux may be used to boot linux using the PXE boot loader which is present on many modern network cards.
  >
  > When using pxelinux, the kernel image is specified using "kernel &lt;relative-path-below /tftpboot&gt;". The nfsroot parameters are passed to the kernel by adding them to the "append" line. It is common to use serial console in conjunction with pxelinux, see [Documentation/admin-guide/serial-console.rst](/kernel/administration/admin-guide/console/serial-console.md) for more information.
  >
  > For more information on isolinux, including how to create bootdisks for prebuilt kernels, see [https://syslinux.zytor.com/](<https://syslinux.zytor.com/>)

<a id="rst-credits"></a>

## Credits

> The nfsroot code in the kernel and the RARP support have been written by Gero Kuhlmann &lt;[gero@gkminix.han.de](<mailto:gero@gkminix.han.de>)&gt;.
>
> The rest of the IP layer autoconfiguration code has been written by Martin Mares &lt;[mj@atrey.karlin.mff.cuni.cz](<mailto:mj@atrey.karlin.mff.cuni.cz>)&gt;.
>
> In order to write the initial version of nfsroot I would like to thank Jens-Uwe Mager &lt;[jum@anubis.han.de](<mailto:jum@anubis.han.de>)&gt; for his help.

---

# pNFS block layout server user guide

_Peios Kernel / Administration / System administration / NFS_

> The Linux NFS server now supports the pNFS block layout extension. In this case the NFS server acts as Metadata Server (MDS) for pNFS, which in addition to handling all the metadata access to the NFS export also hands out layouts to the…

<a id="rst-pnfs-block-layout-server-user-guide"></a>

The Linux NFS server now supports the pNFS block layout extension.  In this case the NFS server acts as Metadata Server (MDS) for pNFS, which in addition to handling all the metadata access to the NFS export also hands out layouts to the clients to directly access the underlying block devices that are shared with the client.

To use pNFS block layouts with the Linux NFS server the exported file system needs to support the pNFS block layouts (currently just XFS), and the file system must sit on shared storage (typically iSCSI) that is accessible to the clients in addition to the MDS.  As of now the file system needs to sit directly on the exported volume, striping or concatenation of volumes on the MDS and clients is not supported yet.

On the server, pNFS block volume support is automatically if the file system support it.  On the client make sure the kernel has the CONFIG_PNFS_BLOCK option enabled, the blkmapd daemon from nfs-utils is running, and the file system is mounted using the NFSv4.1 protocol version (mount -o vers=4.1).

If the nfsd server needs to fence a non-responding client it calls /sbin/nfsd-recall-failed with the first argument set to the IP address of the client, and the second argument set to the device node without the /dev prefix for the file system to be fenced. Below is an example file that shows how to translate the device into a serial number from SCSI EVPD 0x80:



```text
cat > /sbin/nfsd-recall-failed << EOF
```



```sh
#!/bin/sh

CLIENT="$1"
DEV="/dev/$2"
EVPD=`sg_inq --page=0x80 ${DEV} | \
        grep "Unit serial number:" | \
        awk -F ': ' '{print $2}'`

echo "fencing client ${CLIENT} serial ${EVPD}" >> /var/log/pnfsd-fence.log
EOF
```

---

# pNFS SCSI layout server user guide

_Peios Kernel / Administration / System administration / NFS_

> This document describes support for pNFS SCSI layouts in the Linux NFS server. With pNFS SCSI layouts, the NFS server acts as Metadata Server (MDS) for pNFS, which in addition to handling all the metadata access to the NFS export, also…

<a id="rst-pnfs-scsi-layout-server-user-guide"></a>

This document describes support for pNFS SCSI layouts in the Linux NFS server. With pNFS SCSI layouts, the NFS server acts as Metadata Server (MDS) for pNFS, which in addition to handling all the metadata access to the NFS export, also hands out layouts to the clients so that they can directly access the underlying SCSI LUNs that are shared with the client.

To use pNFS SCSI layouts with the Linux NFS server, the exported file system needs to support the pNFS SCSI layouts (currently just XFS), and the file system must sit on a SCSI LUN that is accessible to the clients in addition to the MDS.  As of now the file system needs to sit directly on the exported LUN, striping or concatenation of LUNs on the MDS and clients is not supported yet.

On a server built with CONFIG_NFSD_SCSI, the pNFS SCSI volume support is automatically enabled if the file system is exported using the "pnfs" option and the underlying SCSI device support persistent reservations. On the client make sure the kernel has the CONFIG_PNFS_BLOCK option enabled, and the file system is mounted using the NFSv4.1 protocol version (mount -o vers=4.1).
