AddThis Social Bookmark Button

Print

Building a BSD Netboot Server

by Mikhail Zakharov
09/09/2004

When FreeBSD 5.2.1 appeared, the differences in diskless operations from branch 4.x were so great that the handbook needed revising. That correction occurred recently, so the ISO image of the FreeBSD-5.2.1-Release, written on 25.02.2004, included the obsolete version, which applied to FreeBSD-5.1 (at best). Besides, the guide doesn't cover everything; the steps to build the system server-diskless stations are a maze of variants of realizations, technologies, and descriptions of differences between FreeBSD versions.

While trying not to miss the multitude of the possibilities, I've concentrated on only one method to install FreeBSD-5.2.1-Release as a server for diskless clients. For the sake of precision, I have illustrated the process with a concrete example.

Conventions

As I've confined myself to a single alternative, it's important to lay out some conditions. First, the method here differs from the canonical version in the way it uses rc files in the FreeBSD distribution. For example, diskless stations won't put their file systems in virtual memory; instead, they will use NFS to mount file systems as read-only (/ and /usr) and read-and-write (/etc and /var).

Second, I'll use FreeBSD-5.2.1-Release server for the entire process, along with the following software:

If I don't specify otherwise, install the software from ports.

Related Reading

BSD Hacks
100 Industrial Tip & Tools
By Dru Lavigne

The diskless stations will use the address pool of 192.168.1.10 through 192.168.1.254. The hostname will follow the format "diskless-<the-last-IP-address-octet>", so the hostname "diskless-101" refers to the test diskless workstation (Intel Pentium-90, 16Mb RAM, LAN Intel EtherExpress-100 PXE) with IP address 192.168.1.101/24. I'll used this station for all examples.

An Overview of the Diskless Booting Process

The main point of the problem is to send a FreeBSD kernel over the network to the computer while it boots. The handbook mentions two ways to do it:

  • Preboot eXecution Environment (PXE): Implemented in Intel and some other network adapters.
  • Etherboot: Compiles code that can execute in MS-DOS or from a boot PROM of the LAN adapter. The handbook doesn't mention this option, but it's also possible to use an alternative Netboot project; this is Etherboot's Linux brother. For more information, see the ports net/etherboot and net/netboot) and the web sites of developers.

Both PXE and Etherboot use BOOTP or DHCP to receive information about network addresses. The difference between the two is that PXE uses TFTP to fetch a much smaller program for pxeboot, which then itself loads the kernel by NFS or TFTP, while Etherboot uses TFTP or NFS uploads and boots the kernel from the server.

Nowadays, it's easier to buy a new net card supporting the PXE specification than it is to burn PROM into an old adapter, so I'll skip the methods to boot diskless clients using Etherboot or Netboot. I'll only say that it's far easier to set up Etherboot then Netboot for loading the FreeBSD kernel. PXE is the easiest of all, because it doesn't need any additional software.

When loaded on a diskless station, a FreeBSD kernel mounts the root file system on the resource of NFS-server and calls /sbin/init (or a likely substitute, such as init.bak, oinit, or sysinstall), mounts devfs on /dev, executes the /etc/rc script, and forks a getty process for each relevant terminal device listed in /etc/ttys.

The script /etc/rc, which finishes the booting procedure and starts the main system daemons, is worth mentioning. This script is important for this variant of diskless booting for one more reason. While running /etc/rc, the system needs to substitute one of the diskless client's file systems.

For the sake of saving space on the server hard drive, I've decided to share the root file system for all the diskless clients. That's why it's more reasonable to mount it read-only. As an unfortunate result, /etc will be the same for all of the diskless stations and accessible only for reading. In order to provide the flexibility of creating individual /etc directories for every client, I placed a special operation in /etc/rc to mount the stations' /etc in read-write mode.

It's possible to do the same with the default FreeBSD rc scripts, though they'll store /etc in virtual memory. This isn't very good, in my opinion, because the RAM is doubtless the main and often scarce resource for all diskless stations. That's why I used a different approach. For more information, see the scripts /etc/rc.d/initdiskless and /etc/rc.d/diskless.

Installing a diskless station itself requires little effort and only consists of mounting a PXE-supported network card into the computer case. Then, in accordance with the particular station equipment, you have only to choose the right order of the booting--"boot from LAN," in our case, either in the computer's BIOS in the menu of the LAN adapter itself. On the test station, where the BIOS didn't support booting from LAN, I had to do the configuration through the menu of the network adapter. In order to access the menu of the network card, I had to press Ctrl-S while booting the diskless station.

Now it's clear that the set up's principal work takes place on the server. It's time to configure the server.

Server Configuration

To set up FreeBSD as the diskless station server requires configuring NFS, DHCP, and TFTP. The sequence of this configuration doesn't really matter, but let's follow the logic of the boot process and select this order: DHCP, TFTP, NFS.

Install the server as usual, with one small change. To place the client file systems, allocate two separate partitions, one for "reading only" and the other "reading and writing." Mount these file systems into the following directories of the root file system of the server:

/diskless_ro
/diskless_rw 

In the future, the server will export these file systems with the proper permissions to the diskless clients over NFS. If you can't use these special partitions as the diskless clients file systems, don't make a mistake of putting them on the same physical file system of the server. It would be better to choose subdirectories in /usr, /home or /var. For example, if /usr and /var are different file systems on the server, the client directories can be /usr/diskless_ro and /var/diskless_rw. Such allocation of files corresponds to the NFS specification, which I'll mention again when describing the configuration of the NFS server.

DHCP Server

The first thing required to boot a diskless workstation remotely is to supply it with the information about its IP address, subnet mask, the place of the root file system, and so on. You have a choice of a BOOTP or DHCP server.

Nowadays, BOOTP is rare in comparison with its successor DHCP, so I'll confine myself to the modern alternative. Besides, anyone interested in the configuration of the classic BOOTP server can read about it in the handbook.

For the DHCP server, I use ISC DHCP (isc-dhcp3), which also supports the BOOTP protocol. The basic FreeBSD distribution doesn't include the ISC DHCP, so I installed it from ports. The installation usually resembles:

server# cd /usr/ports/net/isc-dhcp3 && make install clean 

Every diskless client will have NFS shares for writing, so it doesn't make sense to change IP addresses from time to time. In the DHCP server configuration, disable dynamic IP address distribution. Instead, use DHCP in the BOOTP mode (DHCP for BOOTP clients, in the terminology of ISC DHCP).

The main configuration of the DHCP server lives in the file /usr/local/etc/dhcpd.conf. Edit this file in order to make the simple configuration. As there is only one server and one subnet, almost all of this information goes into the global parameters section:

# Server is authoritative for the subnets.
authoritative;                     

# Disable dynamic DNS updates.
ddns-update-style none;            

# Send the client the "hostname", specified in the option
# "host" in the host declaration.
use-host-decl-names on;            

# Set the default gateway.
option routers 192.168.1.1;

# The server from which to upload the initial boot-file.
next-server 192.168.1.2;

# The file to load from the "next-server".
filename "pxeboot";

# The shared root file system of diskless workstations
option root-path "192.168.1.2:/diskless_ro";     

# Network definition.  There are no options because of 
# dynamic distribution of IP-addresses is disabled.
# But DHCP refuses to load without this line, so we
# can't remove it.
subnet 192.168.1.0 netmask 255.255.255.0 { }     

# Diskless station definitions: we must specify
# hostname, IP and MAC addresses for each client

host diskless-10 {                                      
# Hostname which will be sent to the client because of 
# "use-host-decl-names on"

		# Ethernet-address of the workstation LAN adapter
        hardware ethernet 00:0D:9D:8B:BB:48;            

		# Workstation IP-address.
        fixed-address 192.168.1.10;
 }

...

host diskless-101 {
        hardware ethernet 00:0C:29:74:2B:35;
        fixed-address 192.168.1.101;
}

...

host diskless-254 {
        hardware ethernet 00:02:B3:8A:D6:BF;
        fixed-address 192.168.1.103;
} 

Now start the DHCP server:

server# /usr/local/sbin/dhcpd 

If it loads successfully, you'll see a message similar to this:

Internet Software Consortium DHCP Server V3.0.1rc12
Copyright 1995-2003 Internet Software Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
Listening on BPF/fxp0/00:0c:29:f8:78:fc/192.168.1.0/24
Sending on BPF/fxp0/00:0c:29:f8:78:fc/192.168.1.0/24
Sending on Socket/fallback/fallback-net

Run this to start DHCP at boot time:

server# cd /usr/local/etc/rc.d
server# mv isc-dhcpd.sh.sample isc-dhcpd.sh
server# chmod 755 isc-dhcpd.sh

Pages: 1, 2

Next Pagearrow