May 092011
 

Hi All,

In this part, I will go through the install and setup of the needed software.
This list was in Part 1 as the software needed for this :

dnsmasq 2.55
Syslinux 4.02
Memtest86+ 4.10

The first 2 packages are the ones that make the magic happen.
Dnsmasq is a DHCP and TFTP server, which will let the computers that are connected to the network get an IP address and also grab the files it needs to boot from the server.
Syslinux, or more specifically it’s derivative pxelinux will let computers on the network request a file.

Quicklinks :
Part 1
Part 3


Step 1 – Software Install

Anyway, starting from the end of part 1 – we had just installed Debian Linux.
So first thing we do ?
We need to login, preferably as root to do all the configuration stuff first but you can login as your user and then su to root as well or install sudo and use that.

Update sources

So once you’re logged in, you’re ready to install the software. If you are going to use CDs to install the software then you should be able to skip this step, but if it doesn’t work then you can still use the apt-get update command and you should get something similar to this screenshot.

If you have an internet connection, then first thing we need to do is update the sources list with the apt-get update command.

So after we’ve run the apt-get update we should see something similar to above.
That updates the software sources that you selected while you were installing the Debian.

Installing the software

Once the software sources are up to date, you can now install the software that you need with this command : apt-get install dnsmasq syslinux memtest86+
That command will install the 3 packages and any other dependencies that they need to function.
When you run the command you should get something similar to this (I forgot to install memtest at the time of the screenshot 🙁 ) :

Hit enter and you get …

Now you have the software that you need to boot from the network installed !

Step 2 : Configuring the Software

Configuration dnsmasq

First thing I do now is stop dnsmasq and rename it’s configuration files so we can start with a blank configuration file to make it easier to read later.
To stop dnsmasq, you run this command as root : /etc/init.d/dnsmasq stop
Then to rename the config file, you use this command : mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup.

I've done it reversed in this screenshot...

Also this is a good time to unplug the pxe server from the network if it is plugged in, because when we start up dnsmasq again, it will start trying to hand out IP addresses, and if there’s 2 DHCP servers on the network, it may wreak havoc with any new computers trying to get an IP address.

Get the files you need

Next up, you will need to create a directory for the TFTP server to store it’s files.
In this guide, I have chosen to use /tftpboot for the server root.
To create the necessary directory, you run this command, again as root :
mkdir -p /tftpboot/boot.
You will now have a directory called /tftpboot and a sub-directory called /tftpboot/boot created.
You will need these later to store the files you use to network boot computers.
You will also need a /tftpboot/pxelinux.cfg directory created, this is where the configuration files for pxelinux will live.

Next is to copy the files for pxelinux over to the tftpboot directory.
You will need 2 files for this step, pxelinux.0, and menu.c32.
In Debian, the files are located in /usr/lib/syslinux which is where apt-get installed the syslinux package.
Both pxelinux.0 and menu.c32 will need to go into /tftpboot, and to achieve that you will need to run these commands which will copy the files to where we need, again as root :
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /usr/lib/syslinux/menu.c32 /tftpboot

After that, we need to copy the memtest file to the correct directory.
When you first install it, it is installed into /boot for use on the local machine.
To copy it to where we need, we do another cp to where it needs to go.
cp /boot/memtest86+.bin /tftpboot/boot/memtest86+
I’ve removed the .bin extension as PXELINUX won’t boot memtest properly if the bin extension is kept.

Now with all the files in the correct spot, we can move onto the configuration files.

This is the time to setup a static IP address if you haven’t already. The configuration will differ depending on whether you have 1 or 2 network cards, but the general setup remains the same.
I have used 10.1.1.1 as the IP address for my pxe server, and so my configuration file (/etc/network/interfaces) goes :


auto eth0
iface eth0 inet static
address 10.1.1.1
netmask 255.255.255.0

Whether your configuration will be the same or not will depend in your network, but that will work for now.

For dnsmasq, we will need to specify some options to setup the tftp server’s options.
We will need to create a new file with your favourite text editor at /etc/dnsmasq.conf.
The following lines will be added –
interface=eth0
This option is needed if you have more than 1 network card, it will tell dnsmasq to listen on eth0 for the DHCP requests.
dhcp-range=10.1.1.2,10.1.1.10,255.255.255.0
This will set the range of IP addresses that dnsmasq will assign out to computers. For this guide, I have set it up to only assign a range from 10.1.1.2 to 10.1.1.10 with a subnet mask of 255.255.255.0, but you will need to change this to suit your own network.
enable-tftp
This enables the TFTP server in dnsmasq.
tftp-root=/tftpboot/
This sets the root path for the TFTP server, in this guide I have used /tftpboot but you are free to choose your own, or use the default of /var/lib/tftpboot.
dhcp-boot=pxelinux.0,pxeserver,10.1.1.1
This line sets the file, server name, and ip address for network boot clients to boot from.

So all together, you get :

interface=eth0
dhcp-range=10.1.1.2,10.1.1.10,255.255.255.0
enable-tftp
tftp-root=/tftpboot/
dhcp-boot=pxelinux.0,pxeserver,10.1.1.1

After you save this file, you will need to start up dnsmasq again, as we stopped it earlier.
/etc/init.d/dnsmasq start will start it up, and you should get something like :

In /tftpboot/pxelinux.cfg/ we need to create a file called default.
This default file will be the file that all computers will read to get the menu options etc.
In there, we should have the following :

DEFAULT menu.c32
PROMPT 0
MENU TITLE PXE Boot
TIMEOUT 100

LABEL Memtest4.10
MENU LABEL Memtest86+ 4.10
kernel boot/memtest86+

With these 3 files setup, you should be setup to boot from the network.
I got my other virtual PC to boot from the network and I get :

In Part 3, I will add some more functions to your new pxe netboot server 🙂


Some further reading:
PXELinux
Syslinux menu config file documenation

Share

  15 Responses to “How To : Setup a PXE Boot Server on Debian Part 2”

  1. Nice article. Works well to kick of installs, except that if the PXE server is also not your gateway, your netinstalls will fail. The configuration as presented here will hand of the PXE server as the gateway as well as the DHCP/DNS server. If your PXE server is not also a router/firewall, you must add this entry to the the /etc/dnsmasq.conf file:

    dhcp-option=3,

    • Hi Andrew,
      Thanks for that, I hadn’t gotten around to checking out how to do the hand off that function to a different server.
      When I get around to writing a post about it, will have to give you credit for it haha 🙂

      Cheers,
      Lawrence

  2. Hello,
    thaks for good topic it really helps me sort it out how to run pxe server but there is one thning.
    I can’t create In /tftpboot/pxelinux.cfg/ file called default.
    I am trying do like that:
    vi /tftpboot/pxelinux.cfg/defaul but system not creating default file under tftpboot/pxelinux.cfg/
    can you advise how to do that?
    Thank you!

  3. Rim, I had the same problem. I first had to create the folder /tftpboot/pxelinux.cfg/ I was using gedit so I chose save as, and hit the button for create folder. You can also use the mkdir command

  4. Nice tutorial! I created a debian PXE server at my work mainly following this tutorial and it works extremely well. I wanted to extend the PXE boot to another subnet but it won’t allow me to.

    This is my dnsmasq.conf file

    interface=eth2
    dhcp-range=192.168.2.11,192.168.2.200,255.255.255.0
    enable-tftp
    tftp-root=/tftpboot/
    dhcp-boot=pxelinux.0,debianpxeserver,192.186.2.4

    interface=eth3
    dhcp-range=192.168.3.4,192.168.3.200,255.255.255.0
    enable-tftp
    tftp-root=/tftpboot/
    dhcp-boot=pxelinux.0,debianpxeserver,192.168.3.4

    When I add the extra interface and try to restart dnsmasq I get a failed error and says to check line 22.

    Line 22 is
    interface=eth2
    dhcp-range=192.168.2.11,192.168.2.200,255.255.255.0
    enable-tftp
    tftp-root=/tftpboot/
    dhcp-boot=pxelinux.0,pxeserver,192.186.2.4

    interface=eth3
    dhcp-range=192.168.3.4,192.168.3.200,255.255.255.0
    enable-tftp
    –> tftp-root=/tftpboot/ <——– line22
    dhcp-boot=pxelinux.0,pxeserver,192.168.3.4

    and the whole pxe server doesn't work, so I have to comment out the whole eth3 interface to get the PXE server up and running.

    Any suggestions??

    Appreciate it in advance.

  5. I would like to say that these instructions work perfectly with the RaspberryPI with a couple of very minor adjustments

    apt-get install dnsmasq syslinux-common

    For the memtest I used:
    wget http://www.memtest.org/download/2.11/memtest86+-2.11.bin
    Followed by:
    cp /boot/memtest86+-2.11.bin /tftpboot/boot/memtest86+

    For the default file in /tftpboot/pxelinux.cfg/
    I just changed the labels to reflect the version.

    • Good to hear ! Have fun with PXE booting with the Pi 🙂

      • For anyone that wants, there is a full list of BIN files for memtest at
        http://www.memtest.org/download/

        I missed it in my first post, but thank you very much for creating such a simple to follow how-to on this. This is very well explained and the step by step examples are right on target. Since I have completed this, I have added several images to my PI, PXE Server. I am now booting Puppy and DSL from my PI and I will be moving on to Windows Embedded Images soon. Just need to download them from MSDN. Wish me luck…

  6. One year later I find this. Great HowTo but it seems that I cannot get the server to pull from my lappy. Followed instructions through an through. Only difference is i decided to use MINT. Any known blockage or problems? Again ill follow through an see if I’ve created typo’s any where.

  7. Great post! Used it today. Worked first time. Thank you.

Leave a Reply to Ian Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.