Practice
So, today our task is to set up a PXE network boot server based on FreeBSD. What for:
Actually, this article only covers points 1 and 2. I'll write about installing Windows 7 and other OSes via PXE a bit later (since that's about the same amount of material again).
For the PXE server we'll use the syslinux package, together with a local DHCP as well.
A quick note is in order (in case someone doesn't know). A machine that wants to boot via PXE (i.e. over the network) gets its network parameters via DHCP. This means, at minimum, that the DHCP server must be on the same network as the booting computer - i.e. BEFORE the first router.
1) First: we need a DHCP server so that clients can get their network parameters. How to set up such a server on FreeBSD - here's a link.
Once we've set up the server - we need to add the following lines to its config (in the zone description):
where instead of 192.168.0.1 - specify the IP address of the PXE server.
Also change the form of the range declaration:
i.e. add the "dynamic-bootp" option.
we get something like this (this is just an example):
And finally, restart the DHCP server:
2) Installing the TFTP server.
TFTP is needed for the PXE server to work. It doesn't matter whether you'll later serve files over HTTP (which is many times faster), or also via TFTP (which is simpler) - either way we need it.
We'll use tftp-hpa, since in the future you may need to apply substitution rules, which the stock daemon can't do.
Now let's create the directory for the PXE server.
The last directory (yes, no mistake - it's not a file) is the folder for syslinux configuration files. The directories before the last one were created for convenience - to separate the utility files, LiveCD images, and installation images so they don't all end up piled together.
Next, open the file /etc/inetd.conf and bring the tftp line to the following form:
And restart inetd:
You can view the server's logs in /etc/xferlog
3) Installing syslinux.
Don't rush off to the ports tree - yes, syslinux is in ports, but we don't need it from there! We'll download it separately from: link
Unpack it and copy the needed files:
4) This step isn't mandatory, but is highly recommended. The thing is, transferring large files over TFTP is a slow business. But syslinux can use the HTTP protocol for the same purpose - which is much faster.
So we'll set up the following scheme:
So let's set up an HTTP server (if you don't already have one running). I won't describe installing one here. An example of installing Apache 2.2 can be found here.
After installing Apache - add the following entry to its config file:
where instead of 192.168.0.0/16 - specify your own working subnet or set of subnets.
Now let's make a symlink to our PXE directory in Apache's working directory:
and restart Apache:
If you're not using Apache - then configure your server accordingly in a similar fashion.
5) Let's create a configuration file for syslinux. We'll create it using an example based on the MfsBSD LiveCD. This is about the simplest thing you can do.
5a) Download the MfsBSD ISO and put it in the right place.
Note - the link may be different by the time you read this - the MfsBSD project doesn't stand still. It's better to visit their site (link) and download the latest image for the architecture you need (I recommend x86, as it's universal).
5b) Now let's create the syslinux configuration file.
/usr/local/pxe/pxelinux.cfg/default:
Here we set:
Save the file.
PS. If you decided not to use an HTTP server after all - then the file will look like this:
6) Now try booting the machine via PXE. If you did everything correctly - it will boot.
7) Next, the PXE menu can be expanded. Below I'll give an example of my own draft config.
Since syslinux allows creating submenus - my example config consists of several files.
default:
utils.menu:
livecd.menu:
os.menu:
As you can see - the configuration files contain the most varied ways of launching utilities. For example, if we just want to load some ISO into the machine's memory and have it treated as if it were a CD inserted into the drive - we use the memdisk kernel (by the way, don't try feeding it an ISO that's a couple of gigs in size - that's not going to work, believe me).
I won't be posting the actual files themselves (at least not for now) - I recommend digging through discs like Hiren's, Infra, etc. - they contain a number of utilities that suit our purposes (the same MemTest and MHDD, for instance). Opening these discs you can also roughly find out how it's all supposed to be launched.
For the Windows LiveCD images I used ready-made ISOs - and it works. The same goes for the FreeBSD LiveCD. For Linux LiveCDs you need to pick and choose to get one working - not all of them boot.
PS. In the next articles I'll describe how to deploy Windows 7 and Linux over the network. In reality it's not as obvious or simple as it sounds - I had to piece together the Windows 7 install via PXE syslinux, quite literally, from THREE different articles in different languages from different sources.
Applies to: FreeBSD 8.x+
Comments