Mounting the root filesystem via NFS (nfsroot)
|
Mounting the root filesystem via NFS (nfsroot)
|
==============================================
|
==============================================
|
|
|
Written 1996 by Gero Kuhlmann
|
Written 1996 by Gero Kuhlmann
|
|
|
|
|
|
|
If you want to use a diskless system, as an X-terminal or printer
|
If you want to use a diskless system, as an X-terminal or printer
|
server for example, you have to put your root filesystem onto a
|
server for example, you have to put your root filesystem onto a
|
non-disk device. This can either be a ramdisk (see initrd.txt in
|
non-disk device. This can either be a ramdisk (see initrd.txt in
|
this directory for further information) or a filesystem mounted
|
this directory for further information) or a filesystem mounted
|
via NFS. The following text describes on how to use NFS for the
|
via NFS. The following text describes on how to use NFS for the
|
root filesystem. For the rest of this text 'client' means the
|
root filesystem. For the rest of this text 'client' means the
|
diskless system, and 'server' means the NFS server.
|
diskless system, and 'server' means the NFS server.
|
|
|
|
|
|
|
|
|
1.) Enabling nfsroot capabilities
|
1.) Enabling nfsroot capabilities
|
-----------------------------
|
-----------------------------
|
|
|
In order to use nfsroot you have to select support for NFS during
|
In order to use nfsroot you have to select support for NFS during
|
kernel configuration. Note that NFS cannot be loaded as a module
|
kernel configuration. Note that NFS cannot be loaded as a module
|
in this case. The configuration script will then ask you whether
|
in this case. The configuration script will then ask you whether
|
you want to use nfsroot, and if yes what kind of auto configuration
|
you want to use nfsroot, and if yes what kind of auto configuration
|
system you want to use. Selecting both BOOTP and RARP is safe.
|
system you want to use. Selecting both BOOTP and RARP is safe.
|
|
|
|
|
|
|
|
|
2.) Kernel command line
|
2.) Kernel command line
|
-------------------
|
-------------------
|
|
|
When the kernel has been loaded by a boot loader (either by loadlin,
|
When the kernel has been loaded by a boot loader (either by loadlin,
|
LILO or a network boot program) it has to be told what root fs device
|
LILO or a network boot program) it has to be told what root fs device
|
to use, and where to find the server and the name of the directory
|
to use, and where to find the server and the name of the directory
|
on the server to mount as root. This can be established by a couple
|
on the server to mount as root. This can be established by a couple
|
of kernel command line parameters:
|
of kernel command line parameters:
|
|
|
|
|
root=/dev/nfs
|
root=/dev/nfs
|
|
|
This is necessary to enable the pseudo-NFS-device. Note that it's not a
|
This is necessary to enable the pseudo-NFS-device. Note that it's not a
|
real device but just a synonym to tell the kernel to use NFS instead of
|
real device but just a synonym to tell the kernel to use NFS instead of
|
a real device.
|
a real device.
|
|
|
|
|
nfsroot=[:][,]
|
nfsroot=[:][,]
|
|
|
If the nfsroot parameter is NOT give on the command line, the default
|
If the nfsroot parameter is NOT give on the command line, the default
|
"/tftpboot/%s" will be used.
|
"/tftpboot/%s" will be used.
|
|
|
Specifies the IP address of the NFS server. If this field
|
Specifies the IP address of the NFS server. If this field
|
is not given, the default address as determined by the
|
is not given, the default address as determined by the
|
nfsaddrs variable (see below) is used. One use of this
|
nfsaddrs variable (see below) is used. One use of this
|
parameter is for example to allow using different servers
|
parameter is for example to allow using different servers
|
for RARP and NFS. Usually you can leave this blank.
|
for RARP and NFS. Usually you can leave this blank.
|
|
|
Name of the directory on the server to mount as root. If
|
Name of the directory on the server to mount as root. If
|
there is a "%s" token in the string, the token will be
|
there is a "%s" token in the string, the token will be
|
replaced by the ASCII-representation of the client's IP
|
replaced by the ASCII-representation of the client's IP
|
address.
|
address.
|
|
|
Standard NFS options. All options are separated by commas.
|
Standard NFS options. All options are separated by commas.
|
If the options field is not given, the following defaults
|
If the options field is not given, the following defaults
|
will be used:
|
will be used:
|
port = as given by server portmap daemon
|
port = as given by server portmap daemon
|
rsize = 1024
|
rsize = 1024
|
wsize = 1024
|
wsize = 1024
|
timeo = 7
|
timeo = 7
|
retrans = 3
|
retrans = 3
|
acregmin = 3
|
acregmin = 3
|
acregmax = 60
|
acregmax = 60
|
acdirmin = 30
|
acdirmin = 30
|
acdirmax = 60
|
acdirmax = 60
|
flags = hard, nointr, noposix, cto, ac
|
flags = hard, nointr, noposix, cto, ac
|
|
|
|
|
nfsaddrs=::::::
|
nfsaddrs=::::::
|
|
|
If this parameter is missing on the kernel command line, all fields are
|
If this parameter is missing on the kernel command line, all fields are
|
assumed to be empty, and the below mentioned defaults apply. In general
|
assumed to be empty, and the below mentioned defaults apply. In general
|
this means that the kernel tries to configure everything using both
|
this means that the kernel tries to configure everything using both
|
RARP and BOOTP (depending on what has been enabled during kernel confi-
|
RARP and BOOTP (depending on what has been enabled during kernel confi-
|
guration, and if both what protocol answer got in first).
|
guration, and if both what protocol answer got in first).
|
|
|
IP address of the client. If empty, the address will either
|
IP address of the client. If empty, the address will either
|
be determined by RARP or BOOTP. What protocol is used de-
|
be determined by RARP or BOOTP. What protocol is used de-
|
pends on what has been enabled during kernel configuration
|
pends on what has been enabled during kernel configuration
|
and on the parameter. If this parameter is not
|
and on the parameter. If this parameter is not
|
empty, neither RARP nor BOOTP will be used.
|
empty, neither RARP nor BOOTP will be used.
|
|
|
IP address of the NFS server. If RARP is used to determine
|
IP address of the NFS server. If RARP is used to determine
|
the client address and this parameter is NOT empty only
|
the client address and this parameter is NOT empty only
|
replies from the specified server are accepted. To use
|
replies from the specified server are accepted. To use
|
different RARP and NFS server, specify your RARP server
|
different RARP and NFS server, specify your RARP server
|
here (or leave it blank), and specify your NFS server in
|
here (or leave it blank), and specify your NFS server in
|
the nfsroot parameter (see above). If this entry is blank
|
the nfsroot parameter (see above). If this entry is blank
|
the address of the server is used which answered the RARP
|
the address of the server is used which answered the RARP
|
or BOOTP request.
|
or BOOTP request.
|
|
|
IP address of a gateway if the server in on a different
|
IP address of a gateway if the server in on a different
|
subnet. If this entry is empty no gateway is used and the
|
subnet. If this entry is empty no gateway is used and the
|
server is assumed to be on the local network, unless a
|
server is assumed to be on the local network, unless a
|
value has been received by BOOTP.
|
value has been received by BOOTP.
|
|
|
Netmask for local network interface. If this is empty,
|
Netmask for local network interface. If this is empty,
|
the netmask is derived from the client IP address, un-
|
the netmask is derived from the client IP address, un-
|
less a value has been received by BOOTP.
|
less a value has been received by BOOTP.
|
|
|
Name of the client. If empty, the client IP address is
|
Name of the client. If empty, the client IP address is
|
used in ASCII notation, or the value received by BOOTP.
|
used in ASCII notation, or the value received by BOOTP.
|
|
|
Name of network device to use. If this is empty, all
|
Name of network device to use. If this is empty, all
|
devices are used for RARP requests, and the first one
|
devices are used for RARP requests, and the first one
|
found for BOOTP. For NFS the device is used on which
|
found for BOOTP. For NFS the device is used on which
|
either RARP or BOOTP replies have been received. If
|
either RARP or BOOTP replies have been received. If
|
you only have one device you can safely leave this blank.
|
you only have one device you can safely leave this blank.
|
|
|
Method to use for autoconfiguration. If this is either
|
Method to use for autoconfiguration. If this is either
|
'rarp' or 'bootp' the specified protocol is being used.
|
'rarp' or 'bootp' the specified protocol is being used.
|
If the value is 'both' or empty, both protocols are used
|
If the value is 'both' or empty, both protocols are used
|
so far as they have been enabled during kernel configura-
|
so far as they have been enabled during kernel configura-
|
tion. 'none' means no autoconfiguration. In this case you
|
tion. 'none' means no autoconfiguration. In this case you
|
have to specify all necessary values in the fields before.
|
have to specify all necessary values in the fields before.
|
|
|
The parameter can appear alone as the value to the nfsaddrs
|
The parameter can appear alone as the value to the nfsaddrs
|
parameter (without all the ':' characters before) in which case auto-
|
parameter (without all the ':' characters before) in which case auto-
|
configuration is used. However, the 'none' value is not available in
|
configuration is used. However, the 'none' value is not available in
|
that case.
|
that case.
|
|
|
|
|
|
|
|
|
3.) Kernel loader
|
3.) Kernel loader
|
-------------
|
-------------
|
|
|
To get the kernel into memory different approaches can be used. They
|
To get the kernel into memory different approaches can be used. They
|
depend on what facilities are available:
|
depend on what facilities are available:
|
|
|
|
|
3.1) Writing the kernel onto a floppy using dd:
|
3.1) Writing the kernel onto a floppy using dd:
|
As always you can just write the kernel onto a floppy using dd,
|
As always you can just write the kernel onto a floppy using dd,
|
but then it's not possible to use kernel command lines at all.
|
but then it's not possible to use kernel command lines at all.
|
To substitute the 'root=' parameter, create a dummy device on any
|
To substitute the 'root=' parameter, create a dummy device on any
|
linux system with major number 0 and minor number 255 using mknod:
|
linux system with major number 0 and minor number 255 using mknod:
|
|
|
mknod /dev/boot255 c 0 255
|
mknod /dev/boot255 c 0 255
|
|
|
Then copy the kernel zImage file onto a floppy using dd:
|
Then copy the kernel zImage file onto a floppy using dd:
|
|
|
dd if=/usr/src/linux/arch/i386/boot/zImage of=/dev/fd0
|
dd if=/usr/src/linux/arch/i386/boot/zImage of=/dev/fd0
|
|
|
And finally use rdev to set the root device:
|
And finally use rdev to set the root device:
|
|
|
rdev /dev/fd0 /dev/boot255
|
rdev /dev/fd0 /dev/boot255
|
|
|
You can then remove the dummy device /dev/boot255 again. There
|
You can then remove the dummy device /dev/boot255 again. There
|
is no real device available for it.
|
is no real device available for it.
|
The other two kernel command line parameters cannot be substi-
|
The other two kernel command line parameters cannot be substi-
|
tuted with rdev. Therefore, using this method the kernel will
|
tuted with rdev. Therefore, using this method the kernel will
|
by default use RARP and/or BOOTP, and if it gets an answer via
|
by default use RARP and/or BOOTP, and if it gets an answer via
|
RARP will mount the directory /tftpboot// as its
|
RARP will mount the directory /tftpboot// as its
|
root. If it got a BOOTP answer the directory name in that answer
|
root. If it got a BOOTP answer the directory name in that answer
|
is used.
|
is used.
|
|
|
|
|
3.2) Using LILO
|
3.2) Using LILO
|
When using LILO you can specify all necessary command line
|
When using LILO you can specify all necessary command line
|
parameters with the 'append=' command in the LILO configuration
|
parameters with the 'append=' command in the LILO configuration
|
file. However, to use the 'root=' command you also need to
|
file. However, to use the 'root=' command you also need to
|
set up a dummy device as described in 3.1 above. For how to use
|
set up a dummy device as described in 3.1 above. For how to use
|
LILO and its 'append=' command please refer to the LILO
|
LILO and its 'append=' command please refer to the LILO
|
documentation.
|
documentation.
|
|
|
3.3) Using loadlin
|
3.3) Using loadlin
|
When you want to boot Linux from a DOS command prompt without
|
When you want to boot Linux from a DOS command prompt without
|
having a local hard disk to mount as root, you can use loadlin.
|
having a local hard disk to mount as root, you can use loadlin.
|
I was told that it works, but haven't used it myself yet. In
|
I was told that it works, but haven't used it myself yet. In
|
general you should be able to create a kernel command line simi-
|
general you should be able to create a kernel command line simi-
|
lar to how LILO is doing it. Please refer to the loadlin docu-
|
lar to how LILO is doing it. Please refer to the loadlin docu-
|
mentation for further information.
|
mentation for further information.
|
|
|
3.4) Using a bootrom
|
3.4) Using a bootrom
|
This is probably the most elegant way of booting a diskless
|
This is probably the most elegant way of booting a diskless
|
client. With a bootrom the kernel gets loaded using the TFTP
|
client. With a bootrom the kernel gets loaded using the TFTP
|
protocol. As far as I know no commercial bootroms already
|
protocol. As far as I know no commercial bootroms already
|
support booting Linux over the network, but there are two
|
support booting Linux over the network, but there are two
|
free implementations of a bootrom available on sunsite.unc.edu
|
free implementations of a bootrom available on sunsite.unc.edu
|
and its mirrors. They are called 'netboot-nfs' and 'etherboot'.
|
and its mirrors. They are called 'netboot-nfs' and 'etherboot'.
|
Both contain everything you need to boot a diskless Linux client.
|
Both contain everything you need to boot a diskless Linux client.
|
|
|
|
|
|
|
|
|
4.) Credits
|
4.) Credits
|
-------
|
-------
|
|
|
The nfsroot code in the kernel has been written by me, Gero Kuhlmann
|
The nfsroot code in the kernel has been written by me, Gero Kuhlmann
|
, with the BOOTP code and a couple of bug fixes
|
, with the BOOTP code and a couple of bug fixes
|
contributed by Martin Mares . In order to write
|
contributed by Martin Mares . In order to write
|
the initial version of nfsroot I would like to thank Jens-Uwe Mager
|
the initial version of nfsroot I would like to thank Jens-Uwe Mager
|
for his help.
|
for his help.
|
|
|
|
|