| |
|
Domain Registration -
Domain registration & domain search service from just
$5.95/year only |
|
|
|
Webhosting Service -
Webhosting service for single or multiple domain names at affordable price. |
|
|
Back to Index
|
Updated by Jean-François Dockès.
Reorganized and enhanced by Alex
Dupre.
A FreeBSD machine can boot over the network and operate without a local disk, using
filesystems mounted from an NFS server. No system
modification is necessary, beyond standard configuration files. Such a system is
relatively easy to set up because all the necessary elements are readily available:
-
There are at least two possible methods to load the kernel over the network:
-
PXE: The Intel®
Preboot Execution Environment system is a form of smart boot ROM built into some
networking cards or motherboards. See pxeboot(8) for more
details.
-
The etherboot port (net/etherboot) produces ROM-able code to boot kernels over the
network. The code can be either burnt into a boot PROM on a network card, or loaded from
a local floppy (or hard) disk drive, or from a running MS-DOS® system. Many network cards are supported.
-
A sample script (/usr/share/examples/diskless/clone_root)
eases the creation and maintenance of the workstation's root filesystem on the server.
The script will probably require a little customization but it will get you started very
quickly.
-
Standard system startup files exist in /etc to detect and
support a diskless system startup.
-
Swapping, if needed, can be done either to an NFS
file or to a local disk.
There are many ways to set up diskless workstations. Many elements are involved, and
most can be customized to suit local taste. The following will describe variations on the
setup of a complete system, emphasizing simplicity and compatibility with the standard
FreeBSD startup scripts. The system described has the following characteristics:
-
The diskless workstations use a shared read-only root
filesystem, and a shared read-only /usr.
The root filesystem is a copy of a standard FreeBSD root
(typically the server's), with some configuration files overridden by ones specific to
diskless operation or, possibly, to the workstation they belong to.
The parts of the root which have to be writable are overlaid
with mfs(8)
(FreeBSD 4.X) or md(4)
(FreeBSD 5.X) filesystems. Any changes will be lost when the system reboots.
-
The kernel is transferred and loaded either with etherboot
or PXE as some situations may mandate the use of
either method.
Caution: As described, this system is insecure. It should live in a protected
area of a network, and be untrusted by other hosts.
All the information in this section has been tested using FreeBSD releases 4.9-RELEASE
and 5.2.1-RELEASE. The text is primarily structured for 4.X usage. Notes have been
inserted where appropriate to indicate 5.X changes.
Setting up diskless workstations is both relatively straightforward and prone to
errors. These are sometimes difficult to diagnose for a number of reasons. For
example:
In this context, having some knowledge of the background mechanisms involved is very
useful to solve the problems that may arise.
Several operations need to be performed for a successful bootstrap:
-
The machine needs to obtain initial parameters such as its IP address, executable
filename, server name, root path. This is done using the DHCP or BOOTP protocols. DHCP is a compatible extension of BOOTP, and uses the same port
numbers and basic packet format.
It is possible to configure a system to use only BOOTP. The bootpd(8) server
program is included in the base FreeBSD system.
However, DHCP has a number of advantages over BOOTP
(nicer configuration files, possibility of using PXE,
plus many others not directly related to diskless operation), and we will describe mainly
a DHCP configuration, with equivalent exemples using bootpd(8) when
possible. The sample configuration will use the ISC DHCP
software package (release 3.0.1.r12 was installed on the test server).
-
The machine needs to transfer one or several programs to local memory. Either TFTP or NFS are used. The
choice between TFTP and NFS is a compile time option in several places. A common source
of error is to specify filenames for the wrong protocol: TFTP typically transfers all files from a single directory on
the server, and would expect filenames relative to this directory. NFS needs absolute file paths.
-
The possible intermediate bootstrap programs and the kernel need to be initialized and
executed. There are several important variations in this area:
-
PXE will load pxeboot(8), which is a
modified version of the FreeBSD third stage loader. The loader(8) will obtain
most parameters necessary to system startup, and leave them in the kernel environment
before transferring control. It is possible to use a GENERIC
kernel in this case.
-
etherboot, will directly load the kernel, with less
preparation. You will need to build a kernel with specific options.
PXE and etherboot work
equally well with 4.X systems. Because 5.X kernels normally let the loader(8) do more work
for them, PXE is preferred for 5.X systems.
If your BIOS and network cards support PXE, you should probably use it. However, it is still possible
to start a 5.X system with etherboot.
-
Finally, the machine needs to access its filesystems. NFS is used in all cases.
See also diskless(8) manual
page.
The ISC DHCP server can answer both BOOTP and DHCP requests.
As of release 4.9, ISC DHCP 3.0 is not part of the base
system. You will first need to install the net/isc-dhcp3-server port or the corresponding package. Please
refer to Chapter 4 for general information about ports and
packages.
Once ISC DHCP is installed, it needs a configuration file
to run, (normally named /usr/local/etc/dhcpd.conf). Here
follows a commented example, where host margaux uses etherboot and host corbieres uses
PXE:
default-lease-time 600;
max-lease-time 7200;
authoritative;
option domain-name "example.com";
option domain-name-servers 192.168.4.1;
option routers 192.168.4.1;
subnet 192.168.4.0 netmask 255.255.255.0 {
use-host-decl-names on;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.4.255;
host margaux {
hardware ethernet 01:23:45:67:89:ab;
fixed-address margaux.example.com;
next-server 192.168.4.4;
filename "/data/misc/kernel.diskless";
option root-path "192.168.4.4:/data/misc/diskless";
}
host corbieres {
hardware ethernet 00:02:b3:27:62:df;
fixed-address corbieres.example.com;
next-server 192.168.4.4;
filename "pxeboot";
option root-path "192.168.4.4:/data/misc/diskless";
}
}
-

- This option tells dhcpd to send the value in the host declarations as the hostname for the diskless host. An
alternate way would be to add an option host-name margaux inside the host declarations.
-

- The next-server directive designates the TFTP or NFS server to use
for loading loader or kernel file (the default is to use the same host as the DHCP server).
-

- The filename directive defines the file that etherboot or PXE will load for
the next execution step. It must be specified according to the transfer method used. etherboot can be compiled to use NFS or TFTP. The FreeBSD
port configures NFS by default. PXE uses TFTP, which is why
a relative filename is used here (this may depend on the TFTP server configuration, but would be fairly typical). Also,
PXE loads pxeboot, not the
kernel. There are other interesting possibilities, like loading pxeboot from a FreeBSD CD-ROM /boot
directory (as pxeboot(8) can load a
GENERIC kernel, this makes it possible to use PXE to boot from a remote CD-ROM).
-

- The root-path option defines the path to the root
filesystem, in usual NFS notation. When using PXE, it is possible to leave off the host's IP as long as you
do not enable the kernel option BOOTP. The NFS server
will then be the same as the TFTP one.
Here follows an equivalent bootpd configuration (reduced to
one client). This would be found in /etc/bootptab.
Please note that etherboot must be compiled with the
non-default option NO_DHCP_SUPPORT in order to use BOOTP, and
that PXE needs DHCP. The only
obvious advantage of bootpd is that it exists in the base
system.
.def100:\
:hn:ht=1:sa=192.168.4.4:vm=rfc1048:\
:sm=255.255.255.0:\
:ds=192.168.4.1:\
:gw=192.168.4.1:\
:hd="/tftpboot":\
:bf="/kernel.diskless":\
:rp="192.168.4.4:/data/misc/diskless":
margaux:ha=0123456789ab:tc=.def100
Etherboot's Web site
contains extensive documentation mainly intended for Linux systems, but
nonetheless containing useful information. The following will just outline how you would
use etherboot on a FreeBSD system.
You must first install the net/etherboot package or port. The etherboot port can normally be found in /usr/ports/net/etherboot. If the ports tree is installed on your
system, just typing make in this directory should take care of
everything. Else refer to Chapter 4 for information about ports
and packages.
You can change the etherboot configuration (i.e. to use
TFTP instead of NFS) by editing the Config file in
the etherboot source directory.
For our setup, we shall use a boot floppy. For other methods (PROM, or MS-DOS program), please refer to the etherboot documentation.
To make a boot floppy, insert a floppy in the drive on the machine where you installed
etherboot, then change your current directory to the src directory in the etherboot tree and
type:
# gmake bin32/devicetype.fd0
devicetype depends on the type of the Ethernet card in
the diskless workstation. Refer to the NIC file in the same
directory to determine the right devicetype.
By default, the pxeboot(8) loader
loads the kernel via NFS. It can be compiled to use
TFTP instead by specifying the LOADER_TFTP_SUPPORT option in /etc/make.conf. See the comments in /etc/defaults/make.conf (or /usr/share/examples/etc/make.conf for 5.X systems) for
instructions.
There are two other undocumented make.conf options which may
be useful for setting up a serial console diskless machine: BOOT_PXELDR_PROBE_KEYBOARD, and BOOT_PXELDR_ALWAYS_SERIAL (the latter only exists on
FreeBSD 5.X).
To use PXE when the machine starts, you will
usually need to select the Boot from network option in your
BIOS setup, or type a function key during the PC
initialization.
If you are using PXE or etherboot configured to use TFTP, you need to enable tftpd on
the file server:
-
Create a directory from which tftpd will serve the files,
e.g. /tftpboot.
-
Add this line to your /etc/inetd.conf:
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
Note: It appears that at least some PXE
versions want the TCP version of TFTP. In this case, add a second line, replacing dgram udp with stream tcp.
-
Tell inetd to reread its configuration file:
# kill -HUP `cat /var/run/inetd.pid`
You can place the tftpboot directory anywhere on the server.
Make sure that the location is set in both inetd.conf and dhcpd.conf.
In all cases, you also need to enable NFS and
export the appropriate filesystem on the NFS
server.
-
Add this to /etc/rc.conf:
nfs_server_enable="YES"
-
Export the filesystem where the diskless root directory is located by adding the
following to /etc/exports (adjust the volume mount point and
replace margaux corbieres with the names of the diskless
workstations):
/data/misc -alldirs -ro margaux corbieres
-
Tell mountd to reread its configuration file. If you
actually needed to enable NFS in /etc/rc.conf at the first step, you probably want to reboot
instead.
# kill -HUP `cat /var/run/mountd.pid`
If using etherboot, you need to create a kernel
configuration file for the diskless client with the following options (in addition to the
usual ones):
options BOOTP # Use BOOTP to obtain IP address/hostname
options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info
You may also want to use BOOTP_NFSV3, BOOT_COMPAT and BOOTP_WIRED_TO (refer to
LINT in 4.X or NOTES on 5.X).
These option names are historical and slightly misleading as they actually enable
indifferent use of DHCP and BOOTP inside the kernel
(it is also possible to force strict BOOTP or DHCP
use).
Build the kernel (see Chapter 9), and copy it to the
place specified in dhcpd.conf.
Note: When using PXE, building a kernel with
the above options is not strictly necessary (though suggested). Enabling them will cause
more DHCP requests to be issued during kernel startup,
with a small risk of inconsistency between the new values and those retrieved by pxeboot(8) in some
special cases. The advantage of using them is that the host name will be set as a side
effect. Otherwise you will need to set the host name by another method, for example in a
client-specific rc.conf file.
Note: In order to be loadable with etherboot, a 5.X
kernel needs to have the device hints compiled in. You would typically set the following
option in the configuration file (see the NOTES configuration
comments file):
hints "GENERIC.hints"
You need to create a root filesystem for the diskless workstations, in the location
listed as root-path in dhcpd.conf.
The following sections describe two ways to do it.
This is the quickest way to create a root filesystem, but currently it is only
supported on FreeBSD 4.X. This shell script is located at /usr/share/examples/diskless/clone_root and needs customization, at
least to adjust the place where the filesystem will be created (the DEST variable).
Refer to the comments at the top of the script for instructions. They explain how the
base filesystem is built, and how files may be selectively overridden by versions
specific to diskless operation, to a subnetwork, or to an individual workstation. They
also give examples for the diskless /etc/fstab and /etc/rc.conf files.
The README files in /usr/share/examples/diskless contain a lot of interesting
background information, but, together with the other examples in the diskless directory, they actually document a configuration method
which is distinct from the one used by clone_root and the
system startup scripts in /etc, which is a little confusing.
Use them for reference only, except if you prefer the method that they describe, in which
case you will need customized rc scripts.
This method can be applied to either FreeBSD 4.X or 5.X and will install a
complete virgin system (not only the root filesystem) into DESTDIR. All you have to do is simply execute the following
script:
#!/bin/sh
export DESTDIR=/data/misc/diskless
mkdir -p ${DESTDIR}
cd /usr/src; make world && make kernel
cd /usr/src/etc; make distribution
Once done, you may need to customize your /etc/rc.conf and
/etc/fstab placed into DESTDIR according
to your needs.
If needed, a swap file located on the server can be accessed via NFS. One of the methods commonly used to do this has been
discontinued in release 5.X.
The swap file location and size can be specified with BOOTP/DHCP FreeBSD-specific options 128 and 129. Examples of
configuration files for ISC DHCP 3.0 or bootpd follow:
-
Add the following lines to dhcpd.conf:
# Global section
option swap-path code 128 = string;
option swap-size code 129 = integer 32;
host margaux {
... # Standard lines, see above
option swap-path "192.168.4.4:/netswapvolume/netswap";
option swap-size 64000;
}
swap-path is the path to a directory where swap files will
be located. Each file will be named swap.client-ip.
Older versions of dhcpd used a syntax of option option-128 "..., which is no longer supported.
/etc/bootptab would use the following syntax instead:
T128="192.168.4.4:/netswapvolume/netswap":T129=0000fa00
Note: In /etc/bootptab, the swap size must be
expressed in hexadecimal format.
-
On the NFS swap file server, create the swap
file(s)
# mkdir /netswapvolume/netswap
# cd /netswapvolume/netswap
# dd if=/dev/zero bs=1024 count=64000 of=swap.192.168.4.6
# chmod 0600 swap.192.168.4.6
192.168.4.6 is the IP address for the diskless
client.
-
On the NFS swap file server, add the following line
to /etc/exports:
/netswapvolume -maproot=0:10 -alldirs margaux corbieres
Then tell mountd to reread the exports file, as above.
The kernel does not support enabling NFS swap at
boot time. Swap must be enabled by the startup scripts, by mounting a writeable file
system and creating and enabling a swap file. To create a swap file of appropriate size,
you can do like this:
# dd if=/dev/zero of=/path/to/swapfile bs=1k count=1 oseek=100000
To enable it you have to add the following line to your rc.conf:
swapfile=/path/to/swapfile
If the diskless workstation is configured to run X, you will have to adjust the xdm
configuration file, which puts the error log on /usr by
default.
When the server for the root filesystem is not running FreeBSD, you will have to
create the root filesystem on a FreeBSD machine, then copy it to its destination, using
tar or cpio.
In this situation, there are sometimes problems with the special files in /dev, due to differing major/minor integer sizes. A solution to
this problem is to export a directory from the non-FreeBSD server, mount this directory
onto a FreeBSD machine, and run MAKEDEV on the FreeBSD machine
to create the correct device entries (FreeBSD 5.0 and later use
devfs(5) to
allocate device nodes transparently for the user, running MAKEDEV on these versions is pointless).
|
|
|
|
© 2002-2004 Active-Venture.com
Website Hosting
Service
|
| |
|
Disclaimer: This
documentation is provided only for the benefits of our website hosting customers.
For authoritative source of the documentation, please refer to http://www.freebsd.org
|
|
|