365 lines · plain
1===============================================2Mounting the root filesystem via NFS (nfsroot)3===============================================4 5:Authors:6 Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>7 8 Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>9 10 Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>11 12 Updated 2006 by Horms <horms@verge.net.au>13 14 Updated 2018 by Chris Novakovic <chris@chrisn.me.uk>15 16 17 18In order to use a diskless system, such as an X-terminal or printer server for19example, it is necessary for the root filesystem to be present on a non-disk20device. This may be an initramfs (see21Documentation/filesystems/ramfs-rootfs-initramfs.rst), a ramdisk (see22Documentation/admin-guide/initrd.rst) or a filesystem mounted via NFS. The23following text describes on how to use NFS for the root filesystem. For the rest24of this text 'client' means the diskless system, and 'server' means the NFS25server.26 27 28 29 30Enabling nfsroot capabilities31=============================32 33In order to use nfsroot, NFS client support needs to be selected as34built-in during configuration. Once this has been selected, the nfsroot35option will become available, which should also be selected.36 37In the networking options, kernel level autoconfiguration can be selected,38along with the types of autoconfiguration to support. Selecting all of39DHCP, BOOTP and RARP is safe.40 41 42 43 44Kernel command line45===================46 47When the kernel has been loaded by a boot loader (see below) it needs to be48told what root fs device to use. And in the case of nfsroot, where to find49both the server and the name of the directory on the server to mount as root.50This can be established using the following kernel command line parameters:51 52 53root=/dev/nfs54 This is necessary to enable the pseudo-NFS-device. Note that it's not a55 real device but just a synonym to tell the kernel to use NFS instead of56 a real device.57 58 59nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]60 If the `nfsroot' parameter is NOT given on the command line,61 the default ``"/tftpboot/%s"`` will be used.62 63 <server-ip> Specifies the IP address of the NFS server.64 The default address is determined by the ip parameter65 (see below). This parameter allows the use of different66 servers for IP autoconfiguration and NFS.67 68 <root-dir> Name of the directory on the server to mount as root.69 If there is a "%s" token in the string, it will be70 replaced by the ASCII-representation of the client's71 IP address.72 73 <nfs-options> Standard NFS options. All options are separated by commas.74 The following defaults are used::75 76 port = as given by server portmap daemon77 rsize = 409678 wsize = 409679 timeo = 780 retrans = 381 acregmin = 382 acregmax = 6083 acdirmin = 3084 acdirmax = 6085 flags = hard, nointr, noposix, cto, ac86 87 88ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip>89 This parameter tells the kernel how to configure IP addresses of devices90 and also how to set up the IP routing table. It was originally called91 nfsaddrs, but now the boot-time IP configuration works independently of92 NFS, so it was renamed to ip and the old name remained as an alias for93 compatibility reasons.94 95 If this parameter is missing from the kernel command line, all fields are96 assumed to be empty, and the defaults mentioned below apply. In general97 this means that the kernel tries to configure everything using98 autoconfiguration.99 100 The <autoconf> parameter can appear alone as the value to the ip101 parameter (without all the ':' characters before). If the value is102 "ip=off" or "ip=none", no autoconfiguration will take place, otherwise103 autoconfiguration will take place. The most common way to use this104 is "ip=dhcp".105 106 <client-ip> IP address of the client.107 Default: Determined using autoconfiguration.108 109 <server-ip> IP address of the NFS server.110 If RARP is used to determine111 the client address and this parameter is NOT empty only112 replies from the specified server are accepted.113 114 Only required for NFS root. That is autoconfiguration115 will not be triggered if it is missing and NFS root is not116 in operation.117 118 Value is exported to /proc/net/pnp with the prefix "bootserver "119 (see below).120 121 Default: Determined using autoconfiguration.122 The address of the autoconfiguration server is used.123 124 <gw-ip> IP address of a gateway if the server is on a different subnet.125 Default: Determined using autoconfiguration.126 127 <netmask> Netmask for local network interface.128 If unspecified the netmask is derived from the client IP address129 assuming classful addressing.130 131 Default: Determined using autoconfiguration.132 133 <hostname> Name of the client.134 If a '.' character is present, anything135 before the first '.' is used as the client's hostname, and anything136 after it is used as its NIS domain name. May be supplied by137 autoconfiguration, but its absence will not trigger autoconfiguration.138 If specified and DHCP is used, the user-provided hostname (and NIS139 domain name, if present) will be carried in the DHCP request; this140 may cause a DNS record to be created or updated for the client.141 142 Default: Client IP address is used in ASCII notation.143 144 <device> Name of network device to use.145 Default: If the host only has one device, it is used.146 Otherwise the device is determined using147 autoconfiguration. This is done by sending148 autoconfiguration requests out of all devices,149 and using the device that received the first reply.150 151 <autoconf> Method to use for autoconfiguration.152 In the case of options153 which specify multiple autoconfiguration protocols,154 requests are sent using all protocols, and the first one155 to reply is used.156 157 Only autoconfiguration protocols that have been compiled158 into the kernel will be used, regardless of the value of159 this option::160 161 off or none: don't use autoconfiguration162 (do static IP assignment instead)163 on or any: use any protocol available in the kernel164 (default)165 dhcp: use DHCP166 bootp: use BOOTP167 rarp: use RARP168 both: use both BOOTP and RARP but not DHCP169 (old option kept for backwards compatibility)170 171 if dhcp is used, the client identifier can be used by following172 format "ip=dhcp,client-id-type,client-id-value"173 174 Default: any175 176 <dns0-ip> IP address of primary nameserver.177 Value is exported to /proc/net/pnp with the prefix "nameserver "178 (see below).179 180 Default: None if not using autoconfiguration; determined181 automatically if using autoconfiguration.182 183 <dns1-ip> IP address of secondary nameserver.184 See <dns0-ip>.185 186 <ntp0-ip> IP address of a Network Time Protocol (NTP) server.187 Value is exported to /proc/net/ipconfig/ntp_servers, but is188 otherwise unused (see below).189 190 Default: None if not using autoconfiguration; determined191 automatically if using autoconfiguration.192 193 After configuration (whether manual or automatic) is complete, two files194 are created in the following format; lines are omitted if their respective195 value is empty following configuration:196 197 - /proc/net/pnp:198 199 #PROTO: <DHCP|BOOTP|RARP|MANUAL> (depending on configuration method)200 domain <dns-domain> (if autoconfigured, the DNS domain)201 nameserver <dns0-ip> (primary name server IP)202 nameserver <dns1-ip> (secondary name server IP)203 nameserver <dns2-ip> (tertiary name server IP)204 bootserver <server-ip> (NFS server IP)205 206 - /proc/net/ipconfig/ntp_servers:207 208 <ntp0-ip> (NTP server IP)209 <ntp1-ip> (NTP server IP)210 <ntp2-ip> (NTP server IP)211 212 <dns-domain> and <dns2-ip> (in /proc/net/pnp) and <ntp1-ip> and <ntp2-ip>213 (in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration;214 they cannot be specified as part of the "ip=" kernel command line parameter.215 216 Because the "domain" and "nameserver" options are recognised by DNS217 resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems218 that use an NFS root filesystem.219 220 Note that the kernel will not synchronise the system time with any NTP221 servers it discovers; this is the responsibility of a user space process222 (e.g. an initrd/initramfs script that passes the IP addresses listed in223 /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real224 root filesystem if it is on NFS).225 226 227nfsrootdebug228 This parameter enables debugging messages to appear in the kernel229 log at boot time so that administrators can verify that the correct230 NFS mount options, server address, and root path are passed to the231 NFS client.232 233 234rdinit=<executable file>235 To specify which file contains the program that starts system236 initialization, administrators can use this command line parameter.237 The default value of this parameter is "/init". If the specified238 file exists and the kernel can execute it, root filesystem related239 kernel command line parameters, including 'nfsroot=', are ignored.240 241 A description of the process of mounting the root file system can be242 found in Documentation/driver-api/early-userspace/early_userspace_support.rst243 244 245Boot Loader246===========247 248To get the kernel into memory different approaches can be used.249They depend on various facilities being available:250 251 252- Booting from a floppy using syslinux253 254 When building kernels, an easy way to create a boot floppy that uses255 syslinux is to use the zdisk or bzdisk make targets which use zimage256 and bzimage images respectively. Both targets accept the257 FDARGS parameter which can be used to set the kernel command line.258 259 e.g::260 261 make bzdisk FDARGS="root=/dev/nfs"262 263 Note that the user running this command will need to have264 access to the floppy drive device, /dev/fd0265 266 For more information on syslinux, including how to create bootdisks267 for prebuilt kernels, see https://syslinux.zytor.com/268 269 .. note::270 Previously it was possible to write a kernel directly to271 a floppy using dd, configure the boot device using rdev, and272 boot using the resulting floppy. Linux no longer supports this273 method of booting.274 275- Booting from a cdrom using isolinux276 277 When building kernels, an easy way to create a bootable cdrom that278 uses isolinux is to use the isoimage target which uses a bzimage279 image. Like zdisk and bzdisk, this target accepts the FDARGS280 parameter which can be used to set the kernel command line.281 282 e.g::283 284 make isoimage FDARGS="root=/dev/nfs"285 286 The resulting iso image will be arch/<ARCH>/boot/image.iso287 This can be written to a cdrom using a variety of tools including288 cdrecord.289 290 e.g::291 292 cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso293 294 For more information on isolinux, including how to create bootdisks295 for prebuilt kernels, see https://syslinux.zytor.com/296 297- Using LILO298 299 When using LILO all the necessary command line parameters may be300 specified using the 'append=' directive in the LILO configuration301 file.302 303 However, to use the 'root=' directive you also need to create304 a dummy root device, which may be removed after LILO is run.305 306 e.g::307 308 mknod /dev/boot255 c 0 255309 310 For information on configuring LILO, please refer to its documentation.311 312- Using GRUB313 314 When using GRUB, kernel parameter are simply appended after the kernel315 specification: kernel <kernel> <parameters>316 317- Using loadlin318 319 loadlin may be used to boot Linux from a DOS command prompt without320 requiring a local hard disk to mount as root. This has not been321 thoroughly tested by the authors of this document, but in general322 it should be possible configure the kernel command line similarly323 to the configuration of LILO.324 325 Please refer to the loadlin documentation for further information.326 327- Using a boot ROM328 329 This is probably the most elegant way of booting a diskless client.330 With a boot ROM the kernel is loaded using the TFTP protocol. The331 authors of this document are not aware of any no commercial boot332 ROMs that support booting Linux over the network. However, there333 are two free implementations of a boot ROM, netboot-nfs and334 etherboot, both of which are available on sunsite.unc.edu, and both335 of which contain everything you need to boot a diskless Linux client.336 337- Using pxelinux338 339 Pxelinux may be used to boot linux using the PXE boot loader340 which is present on many modern network cards.341 342 When using pxelinux, the kernel image is specified using343 "kernel <relative-path-below /tftpboot>". The nfsroot parameters344 are passed to the kernel by adding them to the "append" line.345 It is common to use serial console in conjunction with pxeliunx,346 see Documentation/admin-guide/serial-console.rst for more information.347 348 For more information on isolinux, including how to create bootdisks349 for prebuilt kernels, see https://syslinux.zytor.com/350 351 352 353 354Credits355=======356 357 The nfsroot code in the kernel and the RARP support have been written358 by Gero Kuhlmann <gero@gkminix.han.de>.359 360 The rest of the IP layer autoconfiguration code has been written361 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>.362 363 In order to write the initial version of nfsroot I would like to thank364 Jens-Uwe Mager <jum@anubis.han.de> for his help.365