nfsroot.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. ===============================================
  2. Mounting the root filesystem via NFS (nfsroot)
  3. ===============================================
  4. :Authors:
  5. Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>
  6. Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  7. Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>
  8. Updated 2006 by Horms <horms@verge.net.au>
  9. Updated 2018 by Chris Novakovic <chris@chrisn.me.uk>
  10. In order to use a diskless system, such as an X-terminal or printer server for
  11. example, it is necessary for the root filesystem to be present on a non-disk
  12. device. This may be an initramfs (see
  13. Documentation/filesystems/ramfs-rootfs-initramfs.rst), a ramdisk (see
  14. Documentation/admin-guide/initrd.rst) or a filesystem mounted via NFS. The
  15. following text describes on how to use NFS for the root filesystem. For the rest
  16. of this text 'client' means the diskless system, and 'server' means the NFS
  17. server.
  18. Enabling nfsroot capabilities
  19. =============================
  20. In order to use nfsroot, NFS client support needs to be selected as
  21. built-in during configuration. Once this has been selected, the nfsroot
  22. option will become available, which should also be selected.
  23. In the networking options, kernel level autoconfiguration can be selected,
  24. along with the types of autoconfiguration to support. Selecting all of
  25. DHCP, BOOTP and RARP is safe.
  26. Kernel command line
  27. ===================
  28. When the kernel has been loaded by a boot loader (see below) it needs to be
  29. told what root fs device to use. And in the case of nfsroot, where to find
  30. both the server and the name of the directory on the server to mount as root.
  31. This can be established using the following kernel command line parameters:
  32. root=/dev/nfs
  33. This is necessary to enable the pseudo-NFS-device. Note that it's not a
  34. real device but just a synonym to tell the kernel to use NFS instead of
  35. a real device.
  36. nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
  37. If the `nfsroot' parameter is NOT given on the command line,
  38. the default ``"/tftpboot/%s"`` will be used.
  39. <server-ip> Specifies the IP address of the NFS server.
  40. The default address is determined by the ip parameter
  41. (see below). This parameter allows the use of different
  42. servers for IP autoconfiguration and NFS.
  43. <root-dir> Name of the directory on the server to mount as root.
  44. If there is a "%s" token in the string, it will be
  45. replaced by the ASCII-representation of the client's
  46. IP address.
  47. <nfs-options> Standard NFS options. All options are separated by commas.
  48. The following defaults are used::
  49. port = as given by server portmap daemon
  50. rsize = 4096
  51. wsize = 4096
  52. timeo = 7
  53. retrans = 3
  54. acregmin = 3
  55. acregmax = 60
  56. acdirmin = 30
  57. acdirmax = 60
  58. flags = hard, nointr, noposix, cto, ac
  59. ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>
  60. This parameter tells the kernel how to configure IP addresses of devices
  61. and also how to set up the IP routing table. It was originally called
  62. nfsaddrs, but now the boot-time IP configuration works independently of
  63. NFS, so it was renamed to ip and the old name remained as an alias for
  64. compatibility reasons.
  65. If this parameter is missing from the kernel command line, all fields are
  66. assumed to be empty, and the defaults mentioned below apply. In general
  67. this means that the kernel tries to configure everything using
  68. autoconfiguration.
  69. The <autoconf> parameter can appear alone as the value to the ip
  70. parameter (without all the ':' characters before). If the value is
  71. "ip=off" or "ip=none", no autoconfiguration will take place, otherwise
  72. autoconfiguration will take place. The most common way to use this
  73. is "ip=dhcp".
  74. <client-ip> IP address of the client.
  75. Default: Determined using autoconfiguration.
  76. <server-ip> IP address of the NFS server.
  77. If RARP is used to determine
  78. the client address and this parameter is NOT empty only
  79. replies from the specified server are accepted.
  80. Only required for NFS root. That is autoconfiguration
  81. will not be triggered if it is missing and NFS root is not
  82. in operation.
  83. Value is exported to /proc/net/pnp with the prefix "bootserver "
  84. (see below).
  85. Default: Determined using autoconfiguration.
  86. The address of the autoconfiguration server is used.
  87. <gw-ip> IP address of a gateway if the server is on a different subnet.
  88. Default: Determined using autoconfiguration.
  89. <netmask> Netmask for local network interface.
  90. If unspecified the netmask is derived from the client IP address
  91. assuming classful addressing.
  92. Default: Determined using autoconfiguration.
  93. <hostname> Name of the client.
  94. If a '.' character is present, anything
  95. before the first '.' is used as the client's hostname, and anything
  96. after it is used as its NIS domain name. May be supplied by
  97. autoconfiguration, but its absence will not trigger autoconfiguration.
  98. If specified and DHCP is used, the user-provided hostname (and NIS
  99. domain name, if present) will be carried in the DHCP request; this
  100. may cause a DNS record to be created or updated for the client.
  101. Default: Client IP address is used in ASCII notation.
  102. <device> Name of network device to use.
  103. Default: If the host only has one device, it is used.
  104. Otherwise the device is determined using
  105. autoconfiguration. This is done by sending
  106. autoconfiguration requests out of all devices,
  107. and using the device that received the first reply.
  108. <autoconf> Method to use for autoconfiguration.
  109. In the case of options
  110. which specify multiple autoconfiguration protocols,
  111. requests are sent using all protocols, and the first one
  112. to reply is used.
  113. Only autoconfiguration protocols that have been compiled
  114. into the kernel will be used, regardless of the value of
  115. this option::
  116. off or none: don't use autoconfiguration
  117. (do static IP assignment instead)
  118. on or any: use any protocol available in the kernel
  119. (default)
  120. dhcp: use DHCP
  121. bootp: use BOOTP
  122. rarp: use RARP
  123. both: use both BOOTP and RARP but not DHCP
  124. (old option kept for backwards compatibility)
  125. if dhcp is used, the client identifier can be used by following
  126. format "ip=dhcp,client-id-type,client-id-value"
  127. Default: any
  128. <dns0-ip> IP address of primary nameserver.
  129. Value is exported to /proc/net/pnp with the prefix "nameserver "
  130. (see below).
  131. Default: None if not using autoconfiguration; determined
  132. automatically if using autoconfiguration.
  133. <dns1-ip> IP address of secondary nameserver.
  134. See <dns0-ip>.
  135. <ntp0-ip> IP address of a Network Time Protocol (NTP) server.
  136. Value is exported to /proc/net/ipconfig/ntp_servers, but is
  137. otherwise unused (see below).
  138. Default: None if not using autoconfiguration; determined
  139. automatically if using autoconfiguration.
  140. After configuration (whether manual or automatic) is complete, two files
  141. are created in the following format; lines are omitted if their respective
  142. value is empty following configuration:
  143. - /proc/net/pnp:
  144. #PROTO: <DHCP|BOOTP|RARP|MANUAL> (depending on configuration method)
  145. domain <dns-domain> (if autoconfigured, the DNS domain)
  146. nameserver <dns0-ip> (primary name server IP)
  147. nameserver <dns1-ip> (secondary name server IP)
  148. nameserver <dns2-ip> (tertiary name server IP)
  149. bootserver <server-ip> (NFS server IP)
  150. - /proc/net/ipconfig/ntp_servers:
  151. <ntp0-ip> (NTP server IP)
  152. <ntp1-ip> (NTP server IP)
  153. <ntp2-ip> (NTP server IP)
  154. <dns-domain> and <dns2-ip> (in /proc/net/pnp) and <ntp1-ip> and <ntp2-ip>
  155. (in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration;
  156. they cannot be specified as part of the "ip=" kernel command line parameter.
  157. Because the "domain" and "nameserver" options are recognised by DNS
  158. resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems
  159. that use an NFS root filesystem.
  160. Note that the kernel will not synchronise the system time with any NTP
  161. servers it discovers; this is the responsibility of a user space process
  162. (e.g. an initrd/initramfs script that passes the IP addresses listed in
  163. /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real
  164. root filesystem if it is on NFS).
  165. nfsrootdebug
  166. This parameter enables debugging messages to appear in the kernel
  167. log at boot time so that administrators can verify that the correct
  168. NFS mount options, server address, and root path are passed to the
  169. NFS client.
  170. rdinit=<executable file>
  171. To specify which file contains the program that starts system
  172. initialization, administrators can use this command line parameter.
  173. The default value of this parameter is "/init". If the specified
  174. file exists and the kernel can execute it, root filesystem related
  175. kernel command line parameters, including 'nfsroot=', are ignored.
  176. A description of the process of mounting the root file system can be
  177. found in Documentation/driver-api/early-userspace/early_userspace_support.rst
  178. Boot Loader
  179. ===========
  180. To get the kernel into memory different approaches can be used.
  181. They depend on various facilities being available:
  182. - Booting from a floppy using syslinux
  183. When building kernels, an easy way to create a boot floppy that uses
  184. syslinux is to use the zdisk or bzdisk make targets which use zimage
  185. and bzimage images respectively. Both targets accept the
  186. FDARGS parameter which can be used to set the kernel command line.
  187. e.g::
  188. make bzdisk FDARGS="root=/dev/nfs"
  189. Note that the user running this command will need to have
  190. access to the floppy drive device, /dev/fd0
  191. For more information on syslinux, including how to create bootdisks
  192. for prebuilt kernels, see https://syslinux.zytor.com/
  193. .. note::
  194. Previously it was possible to write a kernel directly to
  195. a floppy using dd, configure the boot device using rdev, and
  196. boot using the resulting floppy. Linux no longer supports this
  197. method of booting.
  198. - Booting from a cdrom using isolinux
  199. When building kernels, an easy way to create a bootable cdrom that
  200. uses isolinux is to use the isoimage target which uses a bzimage
  201. image. Like zdisk and bzdisk, this target accepts the FDARGS
  202. parameter which can be used to set the kernel command line.
  203. e.g::
  204. make isoimage FDARGS="root=/dev/nfs"
  205. The resulting iso image will be arch/<ARCH>/boot/image.iso
  206. This can be written to a cdrom using a variety of tools including
  207. cdrecord.
  208. e.g::
  209. cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso
  210. For more information on isolinux, including how to create bootdisks
  211. for prebuilt kernels, see https://syslinux.zytor.com/
  212. - Using LILO
  213. When using LILO all the necessary command line parameters may be
  214. specified using the 'append=' directive in the LILO configuration
  215. file.
  216. However, to use the 'root=' directive you also need to create
  217. a dummy root device, which may be removed after LILO is run.
  218. e.g::
  219. mknod /dev/boot255 c 0 255
  220. For information on configuring LILO, please refer to its documentation.
  221. - Using GRUB
  222. When using GRUB, kernel parameter are simply appended after the kernel
  223. specification: kernel <kernel> <parameters>
  224. - Using loadlin
  225. loadlin may be used to boot Linux from a DOS command prompt without
  226. requiring a local hard disk to mount as root. This has not been
  227. thoroughly tested by the authors of this document, but in general
  228. it should be possible configure the kernel command line similarly
  229. to the configuration of LILO.
  230. Please refer to the loadlin documentation for further information.
  231. - Using a boot ROM
  232. This is probably the most elegant way of booting a diskless client.
  233. With a boot ROM the kernel is loaded using the TFTP protocol. The
  234. authors of this document are not aware of any no commercial boot
  235. ROMs that support booting Linux over the network. However, there
  236. are two free implementations of a boot ROM, netboot-nfs and
  237. etherboot, both of which are available on sunsite.unc.edu, and both
  238. of which contain everything you need to boot a diskless Linux client.
  239. - Using pxelinux
  240. Pxelinux may be used to boot linux using the PXE boot loader
  241. which is present on many modern network cards.
  242. When using pxelinux, the kernel image is specified using
  243. "kernel <relative-path-below /tftpboot>". The nfsroot parameters
  244. are passed to the kernel by adding them to the "append" line.
  245. It is common to use serial console in conjunction with pxeliunx,
  246. see Documentation/admin-guide/serial-console.rst for more information.
  247. For more information on isolinux, including how to create bootdisks
  248. for prebuilt kernels, see https://syslinux.zytor.com/
  249. Credits
  250. =======
  251. The nfsroot code in the kernel and the RARP support have been written
  252. by Gero Kuhlmann <gero@gkminix.han.de>.
  253. The rest of the IP layer autoconfiguration code has been written
  254. by Martin Mares <mj@atrey.karlin.mff.cuni.cz>.
  255. In order to write the initial version of nfsroot I would like to thank
  256. Jens-Uwe Mager <jum@anubis.han.de> for his help.