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