1*4882a593Smuzhiyun=============================================== 2*4882a593SmuzhiyunMounting the root filesystem via NFS (nfsroot) 3*4882a593Smuzhiyun=============================================== 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun:Authors: 6*4882a593Smuzhiyun Written 1996 by Gero Kuhlmann <gero@gkminix.han.de> 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz> 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org> 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun Updated 2006 by Horms <horms@verge.net.au> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun Updated 2018 by Chris Novakovic <chris@chrisn.me.uk> 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunIn order to use a diskless system, such as an X-terminal or printer server for 19*4882a593Smuzhiyunexample, it is necessary for the root filesystem to be present on a non-disk 20*4882a593Smuzhiyundevice. This may be an initramfs (see 21*4882a593SmuzhiyunDocumentation/filesystems/ramfs-rootfs-initramfs.rst), a ramdisk (see 22*4882a593SmuzhiyunDocumentation/admin-guide/initrd.rst) or a filesystem mounted via NFS. The 23*4882a593Smuzhiyunfollowing text describes on how to use NFS for the root filesystem. For the rest 24*4882a593Smuzhiyunof this text 'client' means the diskless system, and 'server' means the NFS 25*4882a593Smuzhiyunserver. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunEnabling nfsroot capabilities 31*4882a593Smuzhiyun============================= 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunIn order to use nfsroot, NFS client support needs to be selected as 34*4882a593Smuzhiyunbuilt-in during configuration. Once this has been selected, the nfsroot 35*4882a593Smuzhiyunoption will become available, which should also be selected. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunIn the networking options, kernel level autoconfiguration can be selected, 38*4882a593Smuzhiyunalong with the types of autoconfiguration to support. Selecting all of 39*4882a593SmuzhiyunDHCP, BOOTP and RARP is safe. 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunKernel command line 45*4882a593Smuzhiyun=================== 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunWhen the kernel has been loaded by a boot loader (see below) it needs to be 48*4882a593Smuzhiyuntold what root fs device to use. And in the case of nfsroot, where to find 49*4882a593Smuzhiyunboth the server and the name of the directory on the server to mount as root. 50*4882a593SmuzhiyunThis can be established using the following kernel command line parameters: 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun 53*4882a593Smuzhiyunroot=/dev/nfs 54*4882a593Smuzhiyun This is necessary to enable the pseudo-NFS-device. Note that it's not a 55*4882a593Smuzhiyun real device but just a synonym to tell the kernel to use NFS instead of 56*4882a593Smuzhiyun a real device. 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun 59*4882a593Smuzhiyunnfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] 60*4882a593Smuzhiyun If the `nfsroot' parameter is NOT given on the command line, 61*4882a593Smuzhiyun the default ``"/tftpboot/%s"`` will be used. 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun <server-ip> Specifies the IP address of the NFS server. 64*4882a593Smuzhiyun The default address is determined by the ip parameter 65*4882a593Smuzhiyun (see below). This parameter allows the use of different 66*4882a593Smuzhiyun servers for IP autoconfiguration and NFS. 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun <root-dir> Name of the directory on the server to mount as root. 69*4882a593Smuzhiyun If there is a "%s" token in the string, it will be 70*4882a593Smuzhiyun replaced by the ASCII-representation of the client's 71*4882a593Smuzhiyun IP address. 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun <nfs-options> Standard NFS options. All options are separated by commas. 74*4882a593Smuzhiyun The following defaults are used:: 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun port = as given by server portmap daemon 77*4882a593Smuzhiyun rsize = 4096 78*4882a593Smuzhiyun wsize = 4096 79*4882a593Smuzhiyun timeo = 7 80*4882a593Smuzhiyun retrans = 3 81*4882a593Smuzhiyun acregmin = 3 82*4882a593Smuzhiyun acregmax = 60 83*4882a593Smuzhiyun acdirmin = 30 84*4882a593Smuzhiyun acdirmax = 60 85*4882a593Smuzhiyun flags = hard, nointr, noposix, cto, ac 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun 88*4882a593Smuzhiyunip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>:<ntp0-ip> 89*4882a593Smuzhiyun This parameter tells the kernel how to configure IP addresses of devices 90*4882a593Smuzhiyun and also how to set up the IP routing table. It was originally called 91*4882a593Smuzhiyun nfsaddrs, but now the boot-time IP configuration works independently of 92*4882a593Smuzhiyun NFS, so it was renamed to ip and the old name remained as an alias for 93*4882a593Smuzhiyun compatibility reasons. 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun If this parameter is missing from the kernel command line, all fields are 96*4882a593Smuzhiyun assumed to be empty, and the defaults mentioned below apply. In general 97*4882a593Smuzhiyun this means that the kernel tries to configure everything using 98*4882a593Smuzhiyun autoconfiguration. 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun The <autoconf> parameter can appear alone as the value to the ip 101*4882a593Smuzhiyun parameter (without all the ':' characters before). If the value is 102*4882a593Smuzhiyun "ip=off" or "ip=none", no autoconfiguration will take place, otherwise 103*4882a593Smuzhiyun autoconfiguration will take place. The most common way to use this 104*4882a593Smuzhiyun is "ip=dhcp". 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun <client-ip> IP address of the client. 107*4882a593Smuzhiyun Default: Determined using autoconfiguration. 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun <server-ip> IP address of the NFS server. 110*4882a593Smuzhiyun If RARP is used to determine 111*4882a593Smuzhiyun the client address and this parameter is NOT empty only 112*4882a593Smuzhiyun replies from the specified server are accepted. 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun Only required for NFS root. That is autoconfiguration 115*4882a593Smuzhiyun will not be triggered if it is missing and NFS root is not 116*4882a593Smuzhiyun in operation. 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun Value is exported to /proc/net/pnp with the prefix "bootserver " 119*4882a593Smuzhiyun (see below). 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun Default: Determined using autoconfiguration. 122*4882a593Smuzhiyun The address of the autoconfiguration server is used. 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun <gw-ip> IP address of a gateway if the server is on a different subnet. 125*4882a593Smuzhiyun Default: Determined using autoconfiguration. 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun <netmask> Netmask for local network interface. 128*4882a593Smuzhiyun If unspecified the netmask is derived from the client IP address 129*4882a593Smuzhiyun assuming classful addressing. 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun Default: Determined using autoconfiguration. 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun <hostname> Name of the client. 134*4882a593Smuzhiyun If a '.' character is present, anything 135*4882a593Smuzhiyun before the first '.' is used as the client's hostname, and anything 136*4882a593Smuzhiyun after it is used as its NIS domain name. May be supplied by 137*4882a593Smuzhiyun autoconfiguration, but its absence will not trigger autoconfiguration. 138*4882a593Smuzhiyun If specified and DHCP is used, the user-provided hostname (and NIS 139*4882a593Smuzhiyun domain name, if present) will be carried in the DHCP request; this 140*4882a593Smuzhiyun may cause a DNS record to be created or updated for the client. 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun Default: Client IP address is used in ASCII notation. 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun <device> Name of network device to use. 145*4882a593Smuzhiyun Default: If the host only has one device, it is used. 146*4882a593Smuzhiyun Otherwise the device is determined using 147*4882a593Smuzhiyun autoconfiguration. This is done by sending 148*4882a593Smuzhiyun autoconfiguration requests out of all devices, 149*4882a593Smuzhiyun and using the device that received the first reply. 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun <autoconf> Method to use for autoconfiguration. 152*4882a593Smuzhiyun In the case of options 153*4882a593Smuzhiyun which specify multiple autoconfiguration protocols, 154*4882a593Smuzhiyun requests are sent using all protocols, and the first one 155*4882a593Smuzhiyun to reply is used. 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun Only autoconfiguration protocols that have been compiled 158*4882a593Smuzhiyun into the kernel will be used, regardless of the value of 159*4882a593Smuzhiyun this option:: 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun off or none: don't use autoconfiguration 162*4882a593Smuzhiyun (do static IP assignment instead) 163*4882a593Smuzhiyun on or any: use any protocol available in the kernel 164*4882a593Smuzhiyun (default) 165*4882a593Smuzhiyun dhcp: use DHCP 166*4882a593Smuzhiyun bootp: use BOOTP 167*4882a593Smuzhiyun rarp: use RARP 168*4882a593Smuzhiyun both: use both BOOTP and RARP but not DHCP 169*4882a593Smuzhiyun (old option kept for backwards compatibility) 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun if dhcp is used, the client identifier can be used by following 172*4882a593Smuzhiyun format "ip=dhcp,client-id-type,client-id-value" 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun Default: any 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun <dns0-ip> IP address of primary nameserver. 177*4882a593Smuzhiyun Value is exported to /proc/net/pnp with the prefix "nameserver " 178*4882a593Smuzhiyun (see below). 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun Default: None if not using autoconfiguration; determined 181*4882a593Smuzhiyun automatically if using autoconfiguration. 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun <dns1-ip> IP address of secondary nameserver. 184*4882a593Smuzhiyun See <dns0-ip>. 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun <ntp0-ip> IP address of a Network Time Protocol (NTP) server. 187*4882a593Smuzhiyun Value is exported to /proc/net/ipconfig/ntp_servers, but is 188*4882a593Smuzhiyun otherwise unused (see below). 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun Default: None if not using autoconfiguration; determined 191*4882a593Smuzhiyun automatically if using autoconfiguration. 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun After configuration (whether manual or automatic) is complete, two files 194*4882a593Smuzhiyun are created in the following format; lines are omitted if their respective 195*4882a593Smuzhiyun value is empty following configuration: 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun - /proc/net/pnp: 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun #PROTO: <DHCP|BOOTP|RARP|MANUAL> (depending on configuration method) 200*4882a593Smuzhiyun domain <dns-domain> (if autoconfigured, the DNS domain) 201*4882a593Smuzhiyun nameserver <dns0-ip> (primary name server IP) 202*4882a593Smuzhiyun nameserver <dns1-ip> (secondary name server IP) 203*4882a593Smuzhiyun nameserver <dns2-ip> (tertiary name server IP) 204*4882a593Smuzhiyun bootserver <server-ip> (NFS server IP) 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun - /proc/net/ipconfig/ntp_servers: 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun <ntp0-ip> (NTP server IP) 209*4882a593Smuzhiyun <ntp1-ip> (NTP server IP) 210*4882a593Smuzhiyun <ntp2-ip> (NTP server IP) 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun <dns-domain> and <dns2-ip> (in /proc/net/pnp) and <ntp1-ip> and <ntp2-ip> 213*4882a593Smuzhiyun (in /proc/net/ipconfig/ntp_servers) are requested during autoconfiguration; 214*4882a593Smuzhiyun they cannot be specified as part of the "ip=" kernel command line parameter. 215*4882a593Smuzhiyun 216*4882a593Smuzhiyun Because the "domain" and "nameserver" options are recognised by DNS 217*4882a593Smuzhiyun resolvers, /etc/resolv.conf is often linked to /proc/net/pnp on systems 218*4882a593Smuzhiyun that use an NFS root filesystem. 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun Note that the kernel will not synchronise the system time with any NTP 221*4882a593Smuzhiyun servers it discovers; this is the responsibility of a user space process 222*4882a593Smuzhiyun (e.g. an initrd/initramfs script that passes the IP addresses listed in 223*4882a593Smuzhiyun /proc/net/ipconfig/ntp_servers to an NTP client before mounting the real 224*4882a593Smuzhiyun root filesystem if it is on NFS). 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun 227*4882a593Smuzhiyunnfsrootdebug 228*4882a593Smuzhiyun This parameter enables debugging messages to appear in the kernel 229*4882a593Smuzhiyun log at boot time so that administrators can verify that the correct 230*4882a593Smuzhiyun NFS mount options, server address, and root path are passed to the 231*4882a593Smuzhiyun NFS client. 232*4882a593Smuzhiyun 233*4882a593Smuzhiyun 234*4882a593Smuzhiyunrdinit=<executable file> 235*4882a593Smuzhiyun To specify which file contains the program that starts system 236*4882a593Smuzhiyun initialization, administrators can use this command line parameter. 237*4882a593Smuzhiyun The default value of this parameter is "/init". If the specified 238*4882a593Smuzhiyun file exists and the kernel can execute it, root filesystem related 239*4882a593Smuzhiyun kernel command line parameters, including 'nfsroot=', are ignored. 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun A description of the process of mounting the root file system can be 242*4882a593Smuzhiyun found in Documentation/driver-api/early-userspace/early_userspace_support.rst 243*4882a593Smuzhiyun 244*4882a593Smuzhiyun 245*4882a593SmuzhiyunBoot Loader 246*4882a593Smuzhiyun=========== 247*4882a593Smuzhiyun 248*4882a593SmuzhiyunTo get the kernel into memory different approaches can be used. 249*4882a593SmuzhiyunThey depend on various facilities being available: 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun 252*4882a593Smuzhiyun- Booting from a floppy using syslinux 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun When building kernels, an easy way to create a boot floppy that uses 255*4882a593Smuzhiyun syslinux is to use the zdisk or bzdisk make targets which use zimage 256*4882a593Smuzhiyun and bzimage images respectively. Both targets accept the 257*4882a593Smuzhiyun FDARGS parameter which can be used to set the kernel command line. 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun e.g:: 260*4882a593Smuzhiyun 261*4882a593Smuzhiyun make bzdisk FDARGS="root=/dev/nfs" 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun Note that the user running this command will need to have 264*4882a593Smuzhiyun access to the floppy drive device, /dev/fd0 265*4882a593Smuzhiyun 266*4882a593Smuzhiyun For more information on syslinux, including how to create bootdisks 267*4882a593Smuzhiyun for prebuilt kernels, see https://syslinux.zytor.com/ 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun .. note:: 270*4882a593Smuzhiyun Previously it was possible to write a kernel directly to 271*4882a593Smuzhiyun a floppy using dd, configure the boot device using rdev, and 272*4882a593Smuzhiyun boot using the resulting floppy. Linux no longer supports this 273*4882a593Smuzhiyun method of booting. 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun- Booting from a cdrom using isolinux 276*4882a593Smuzhiyun 277*4882a593Smuzhiyun When building kernels, an easy way to create a bootable cdrom that 278*4882a593Smuzhiyun uses isolinux is to use the isoimage target which uses a bzimage 279*4882a593Smuzhiyun image. Like zdisk and bzdisk, this target accepts the FDARGS 280*4882a593Smuzhiyun parameter which can be used to set the kernel command line. 281*4882a593Smuzhiyun 282*4882a593Smuzhiyun e.g:: 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun make isoimage FDARGS="root=/dev/nfs" 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun The resulting iso image will be arch/<ARCH>/boot/image.iso 287*4882a593Smuzhiyun This can be written to a cdrom using a variety of tools including 288*4882a593Smuzhiyun cdrecord. 289*4882a593Smuzhiyun 290*4882a593Smuzhiyun e.g:: 291*4882a593Smuzhiyun 292*4882a593Smuzhiyun cdrecord dev=ATAPI:1,0,0 arch/x86/boot/image.iso 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun For more information on isolinux, including how to create bootdisks 295*4882a593Smuzhiyun for prebuilt kernels, see https://syslinux.zytor.com/ 296*4882a593Smuzhiyun 297*4882a593Smuzhiyun- Using LILO 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun When using LILO all the necessary command line parameters may be 300*4882a593Smuzhiyun specified using the 'append=' directive in the LILO configuration 301*4882a593Smuzhiyun file. 302*4882a593Smuzhiyun 303*4882a593Smuzhiyun However, to use the 'root=' directive you also need to create 304*4882a593Smuzhiyun a dummy root device, which may be removed after LILO is run. 305*4882a593Smuzhiyun 306*4882a593Smuzhiyun e.g:: 307*4882a593Smuzhiyun 308*4882a593Smuzhiyun mknod /dev/boot255 c 0 255 309*4882a593Smuzhiyun 310*4882a593Smuzhiyun For information on configuring LILO, please refer to its documentation. 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun- Using GRUB 313*4882a593Smuzhiyun 314*4882a593Smuzhiyun When using GRUB, kernel parameter are simply appended after the kernel 315*4882a593Smuzhiyun specification: kernel <kernel> <parameters> 316*4882a593Smuzhiyun 317*4882a593Smuzhiyun- Using loadlin 318*4882a593Smuzhiyun 319*4882a593Smuzhiyun loadlin may be used to boot Linux from a DOS command prompt without 320*4882a593Smuzhiyun requiring a local hard disk to mount as root. This has not been 321*4882a593Smuzhiyun thoroughly tested by the authors of this document, but in general 322*4882a593Smuzhiyun it should be possible configure the kernel command line similarly 323*4882a593Smuzhiyun to the configuration of LILO. 324*4882a593Smuzhiyun 325*4882a593Smuzhiyun Please refer to the loadlin documentation for further information. 326*4882a593Smuzhiyun 327*4882a593Smuzhiyun- Using a boot ROM 328*4882a593Smuzhiyun 329*4882a593Smuzhiyun This is probably the most elegant way of booting a diskless client. 330*4882a593Smuzhiyun With a boot ROM the kernel is loaded using the TFTP protocol. The 331*4882a593Smuzhiyun authors of this document are not aware of any no commercial boot 332*4882a593Smuzhiyun ROMs that support booting Linux over the network. However, there 333*4882a593Smuzhiyun are two free implementations of a boot ROM, netboot-nfs and 334*4882a593Smuzhiyun etherboot, both of which are available on sunsite.unc.edu, and both 335*4882a593Smuzhiyun of which contain everything you need to boot a diskless Linux client. 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun- Using pxelinux 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun Pxelinux may be used to boot linux using the PXE boot loader 340*4882a593Smuzhiyun which is present on many modern network cards. 341*4882a593Smuzhiyun 342*4882a593Smuzhiyun When using pxelinux, the kernel image is specified using 343*4882a593Smuzhiyun "kernel <relative-path-below /tftpboot>". The nfsroot parameters 344*4882a593Smuzhiyun are passed to the kernel by adding them to the "append" line. 345*4882a593Smuzhiyun It is common to use serial console in conjunction with pxeliunx, 346*4882a593Smuzhiyun see Documentation/admin-guide/serial-console.rst for more information. 347*4882a593Smuzhiyun 348*4882a593Smuzhiyun For more information on isolinux, including how to create bootdisks 349*4882a593Smuzhiyun for prebuilt kernels, see https://syslinux.zytor.com/ 350*4882a593Smuzhiyun 351*4882a593Smuzhiyun 352*4882a593Smuzhiyun 353*4882a593Smuzhiyun 354*4882a593SmuzhiyunCredits 355*4882a593Smuzhiyun======= 356*4882a593Smuzhiyun 357*4882a593Smuzhiyun The nfsroot code in the kernel and the RARP support have been written 358*4882a593Smuzhiyun by Gero Kuhlmann <gero@gkminix.han.de>. 359*4882a593Smuzhiyun 360*4882a593Smuzhiyun The rest of the IP layer autoconfiguration code has been written 361*4882a593Smuzhiyun by Martin Mares <mj@atrey.karlin.mff.cuni.cz>. 362*4882a593Smuzhiyun 363*4882a593Smuzhiyun In order to write the initial version of nfsroot I would like to thank 364*4882a593Smuzhiyun Jens-Uwe Mager <jum@anubis.han.de> for his help. 365