nfsroot.txt
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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