nfsroot.txt 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. If you want to use a diskless system, as an X-terminal or printer
  7. server for example, you have to put your root filesystem onto a
  8. non-disk device. This can either be a ramdisk (see initrd.txt in
  9. this directory for further information) or a filesystem mounted
  10. via NFS. The following text describes on how to use NFS for the
  11. root filesystem. For the rest of this text 'client' means the
  12. diskless system, and 'server' means the NFS server.
  13. 1.) Enabling nfsroot capabilities
  14. -----------------------------
  15. In order to use nfsroot you have to select support for NFS during
  16. kernel configuration. Note that NFS cannot be loaded as a module
  17. in this case. The configuration script will then ask you whether
  18. you want to use nfsroot, and if yes what kind of auto configuration
  19. system you want to use. Selecting both BOOTP and RARP is safe.
  20. 2.) Kernel command line
  21. -------------------
  22. When the kernel has been loaded by a boot loader (either by loadlin,
  23. LILO or a network boot program) it has to be told what root fs device
  24. to use, and where to find the server and the name of the directory
  25. on the server to mount as root. This can be established by a couple
  26. of kernel command line parameters:
  27. root=/dev/nfs
  28. This is necessary to enable the pseudo-NFS-device. Note that it's not a
  29. real device but just a synonym to tell the kernel to use NFS instead of
  30. a real device.
  31. nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
  32. If the `nfsroot' parameter is NOT given on the command line, the default
  33. "/tftpboot/%s" will be used.
  34. <server-ip> Specifies the IP address of the NFS server. If this field
  35. is not given, the default address as determined by the
  36. `ip' variable (see below) is used. One use of this
  37. parameter is for example to allow using different servers
  38. for RARP and NFS. Usually you can leave this blank.
  39. <root-dir> Name of the directory on the server to mount as root. If
  40. there is a "%s" token in the string, the token will be
  41. replaced by the ASCII-representation of the client's IP
  42. address.
  43. <nfs-options> Standard NFS options. All options are separated by commas.
  44. If the options field is not given, the following defaults
  45. will be used:
  46. port = as given by server portmap daemon
  47. rsize = 1024
  48. wsize = 1024
  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. 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 `nfsaddrs',
  59. but now the boot-time IP configuration works independently of NFS, so it
  60. was renamed to `ip' and the old name remained as an alias for compatibility
  61. 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 both
  65. RARP and BOOTP (depending on what has been enabled during kernel confi-
  66. guration, and if both what protocol answer got in first).
  67. <client-ip> IP address of the client. If empty, the address will either
  68. be determined by RARP or BOOTP. What protocol is used de-
  69. pends on what has been enabled during kernel configuration
  70. and on the <autoconf> parameter. If this parameter is not
  71. empty, neither RARP nor BOOTP will be used.
  72. <server-ip> IP address of the NFS server. If RARP is used to determine
  73. the client address and this parameter is NOT empty only
  74. replies from the specified server are accepted. To use
  75. different RARP and NFS server, specify your RARP server
  76. here (or leave it blank), and specify your NFS server in
  77. the `nfsroot' parameter (see above). If this entry is blank
  78. the address of the server is used which answered the RARP
  79. or BOOTP request.
  80. <gw-ip> IP address of a gateway if the server is on a different
  81. subnet. If this entry is empty no gateway is used and the
  82. server is assumed to be on the local network, unless a
  83. value has been received by BOOTP.
  84. <netmask> Netmask for local network interface. If this is empty,
  85. the netmask is derived from the client IP address assuming
  86. classful addressing, unless overridden in BOOTP reply.
  87. <hostname> Name of the client. If empty, the client IP address is
  88. used in ASCII notation, or the value received by BOOTP.
  89. <device> Name of network device to use. If this is empty, all
  90. devices are used for RARP and BOOTP requests, and the
  91. first one we receive a reply on is configured. If you have
  92. only one device, you can safely leave this blank.
  93. <autoconf> Method to use for autoconfiguration. If this is either
  94. 'rarp' or 'bootp', the specified protocol is used.
  95. If the value is 'both' or empty, both protocols are used
  96. so far as they have been enabled during kernel configura-
  97. tion. 'off' means no autoconfiguration.
  98. The <autoconf> parameter can appear alone as the value to the `ip'
  99. parameter (without all the ':' characters before) in which case auto-
  100. configuration is used.
  101. 3.) Kernel loader
  102. -------------
  103. To get the kernel into memory different approaches can be used. They
  104. depend on what facilities are available:
  105. 3.1) Writing the kernel onto a floppy using dd:
  106. As always you can just write the kernel onto a floppy using dd,
  107. but then it's not possible to use kernel command lines at all.
  108. To substitute the 'root=' parameter, create a dummy device on any
  109. linux system with major number 0 and minor number 255 using mknod:
  110. mknod /dev/boot255 c 0 255
  111. Then copy the kernel zImage file onto a floppy using dd:
  112. dd if=/usr/src/linux/arch/i386/boot/zImage of=/dev/fd0
  113. And finally use rdev to set the root device:
  114. rdev /dev/fd0 /dev/boot255
  115. You can then remove the dummy device /dev/boot255 again. There
  116. is no real device available for it.
  117. The other two kernel command line parameters cannot be substi-
  118. tuted with rdev. Therefore, using this method the kernel will
  119. by default use RARP and/or BOOTP, and if it gets an answer via
  120. RARP will mount the directory /tftpboot/<client-ip>/ as its
  121. root. If it got a BOOTP answer the directory name in that answer
  122. is used.
  123. 3.2) Using LILO
  124. When using LILO you can specify all necessary command line
  125. parameters with the 'append=' command in the LILO configuration
  126. file. However, to use the 'root=' command you also need to
  127. set up a dummy device as described in 3.1 above. For how to use
  128. LILO and its 'append=' command please refer to the LILO
  129. documentation.
  130. 3.3) Using GRUB
  131. When you use GRUB, you simply append the parameters after the kernel
  132. specification: "kernel <kernel> <parameters>" (without the quotes).
  133. 3.4) Using loadlin
  134. When you want to boot Linux from a DOS command prompt without
  135. having a local hard disk to mount as root, you can use loadlin.
  136. I was told that it works, but haven't used it myself yet. In
  137. general you should be able to create a kernel command line simi-
  138. lar to how LILO is doing it. Please refer to the loadlin docu-
  139. mentation for further information.
  140. 3.5) Using a boot ROM
  141. This is probably the most elegant way of booting a diskless
  142. client. With a boot ROM the kernel gets loaded using the TFTP
  143. protocol. As far as I know, no commercial boot ROMs yet
  144. support booting Linux over the network, but there are two
  145. free implementations of a boot ROM available on sunsite.unc.edu
  146. and its mirrors. They are called 'netboot-nfs' and 'etherboot'.
  147. Both contain everything you need to boot a diskless Linux client.
  148. 3.6) Using pxelinux
  149. Using pxelinux you specify the kernel you built with
  150. "kernel <relative-path-below /tftpboot>". The nfsroot parameters
  151. are passed to the kernel by adding them to the "append" line.
  152. You may perhaps also want to fine tune the console output,
  153. see Documentation/serial-console.txt for serial console help.
  154. 4.) Credits
  155. -------
  156. The nfsroot code in the kernel and the RARP support have been written
  157. by Gero Kuhlmann <gero@gkminix.han.de>.
  158. The rest of the IP layer autoconfiguration code has been written
  159. by Martin Mares <mj@atrey.karlin.mff.cuni.cz>.
  160. In order to write the initial version of nfsroot I would like to thank
  161. Jens-Uwe Mager <jum@anubis.han.de> for his help.