nfsroot.txt 11 KB

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