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