nfsroot.txt 13 KB

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