In Part 1, you should have learned how to set up a TFTP server and configure your router for network booting.

So let’s add some useful stuff to boot from network.

Here’s the list so far. This list will grow with time, so it’s probably easier just to search for when it does get huge. If anyone has any requests, please post in the comments. If anyone has their own instructions, I’ll amend my list (with credit)

-Generic ISO
-Debian Squeeze amd64
-Parted Magic

-Generic ISO
A few notes of caution here, whatever ISO you load needs to be smaller in size than the amount of RAM you have in the system since it loads the entire ISO into memory. This means that it’s probably a BAD idea to load a DVD sized ISO. This is more suited to tools like Memtest (which is listed below). You can load things like UBCD and Hiren’s, but it takes a significantly long time to boot. It’s better to extract the particular tool you need and load that instead of trying to load an entire ISO.

Despite the warnings above, someone out there I know is gonna try loading a Windows ISO. Let me just tell you now that it won’t work. It’s a long story as to why. I’ll cover loading Windows OSes in Part 3.

Here’s a generic template to stick in /srv/tftp/pxelinux.cfg/default:

        MENU LABEL [Name of ISO]
        LINUX memdisk
        append iso initrd=dir/to/iso.iso

Just make the necessary changes to reflect your particular ISO.

If you have a file server to have a central place to store all your ISOs, you may want to use that directory to serve up said ISOs. It would easily beat out copying ISOs to and from your TFTP directory. You may try to symlink your way in, but you’ll quickly find out that you’re chrooted. There is a way to do it: unionfs-fuse.

Before doing anything, you’ll have to mount your file server, which is outside the scope of this post.
Consult the manufacturer of your file server to see what it serves up in terms of protocol and then consult Google.
You’ll need at least read permissions.

First, you’ll have to amend your sources list at /etc/apt/sources.list to include this line:

deb squeeze-backports main

Now let’s do some installing

apt-get update
apt-get -t squeeze-backports install unionfs-fuse

Now set up your directory and overlay your file server’s directory to the iso directory:

mkdir /srv/tftp/iso
unionfs-fuse -o allow_other /directory/to/your/ISOs/on/your/fileserver=RO /srv/tftp/iso

This won’t survive a reboot. If you want it to, you’ll have to amend your /etc/fstab and add this line:

unionfs-fuse#/directory/to/your/ISOs/on/your/fileserver=ro /srv/tftp/iso fuse default_permissions,allow_other 0 0

-Debian Squeeze amd64-
First off, let’s make some directories to make organization easier:

mkdir -p /srv/tftp/debian/squeeze/amd64
cd /srv/tftp/debian/squeeze/amd64

And let’s download the necessary files:


Now let’s populate the default file. Add this to /srv/tftp/pxelinux.cfg/default

LABEL DebianSqueezeamd64
        MENU LABEL Debian Squeeze amd64
        kernel debian/squeeze/amd64/linux
        append initrd=debian/squeeze/amd64/initrd.gz

NOTE: Unless you have a local repo, each time you install you’re gonna be downloading the entire OS from the internet.
I’ll cover how to setup a local repo one of these days. Keeping 100GB on a file server somewhere (to me at least) is worth it if you deploy any sort of VMs at all.

Let’s do the setup:

mkdir /srv/tftp/iso
cd /srv/tftp/iso

And the additions to /srv/tftp/pxelinux.cfg/default

LABEL Memtest
        MENU LABEL Memtest86+
        LINUX memdisk
        append iso initrd=iso/mt420.iso

-Parted Magic-
First, let’s setup the directories:

cd /srv/tftp
mv pmagic-pxe-6.6/pmagic /srv/tftp/
rm -rf pmagic-pxe-6.6

And the additions to /srv/tftp/pxelinux.cfg/default

LABEL pmagic
        MENU LABEL Parted Magic
        LINUX pmagic/bzImage
        INITRD pmagic/initramfs
        APPEND edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal loglevel=9 max_loop=256


NOTE: I’m gonna make reference to “CD” a lot in this post. Replace “CD” with basically any round disc based media that may be appropriate.

Every time someone makes a post somewhere about “burn an ISO to a CD” or “Just make a bootable USB flash drive” I laugh. The amount of work/waste behind it is laughable. Not to mention that once a CD is burnt, it’s forever. Unless you have a rewritable, but those are expensive. Plus you need pesky CD drives. Or spare USB Flash Drives. With the advent of the internet and Dropbox (Shameless referral link. If you don’t have Dropbox by now, please sign up using the link. You get an additional 250MB if you use the referral.) there’s very little use for flash drives any more.
And with those new fangled netbooks not having CD Drives and external CD drives costing money, there’s more and more reason to have your own PXE server.

Having a little server somewhere serving up all sorts of bootable goodness is frickin’ awesome. No more hunting for that stack of blank CDs or using program after program to make that USB Flash Drive bootable. Plus if you have some of the fancier IP phones, you can auto provision the device via TFTP. But that’s another show.
Here’s a step by step tutorial on how to get your own PXE server.

Before you get started, make sure that the DHCP server on your network supports DHCP Option 66 and 67. Mikrotik and pfSense both support this. Consumer routers do not. Some 3rd party firmwares might. I’ll cover configuration on Mikrotik and pfSense. Otherwise you’ll have to also install a DHCP server that does.

First, set up a server with Debian Squeeze on it. It doesn’t matter what kind of server, but in this case a Virtual Machine is probably best. Unless you have a room full of techs, this machine will probably sit idle 99.99% of the time. At least if it’s on a Virtual Server, the host can allocate most of the cycles elsewhere when it’s idle.

Let’s get all the packages installed.

apt-get install tftpd-hpa syslinux unzip

You could use dnsmasq if you like, especially if you have a router with a DHCP server that fails. But for simplicity sake, this tutorial will use tftpd-hpa.

tftpd-hpa is gonna ask where you want to serve files up from. The default location is fine. Change it if you like.
Bonus points if you have a file server mounted and have it serving up files from a directory there. This way you don’t have to screw with SCP. For now, we’ll leave it as /srv/tftp

Let’s make sure TFTP is running.

netstat -a | grep tftp

If you see something like

udp 0 0 *:tftp *:*

you’re good to go.

Time to copy some basic files and make a directory:

mkdir /srv/tftp/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /srv/tftp
cp /usr/lib/syslinux/menu.c32 /srv/tftp
cp /usr/lib/syslinux/memdisk /srv/tftp
cp /usr/lib/syslinux/mboot.c32 /srv/tftp
cp /usr/lib/syslinux/chain.c32 /srv/tftp
touch /srv/tftp/pxelinux.cfg/default

Now edit /srv/tftp/pxelinux.cfg/default and shove this in it:

default menu.c32
prompt 0
timeout 100

LABEL local
        MENU LABEL --Boot Local Disk--
        LOCALBOOT 0

You’ll need to add more to this file later. This is basically a placeholder until we fill it with useful stuff.
This file basically just tells PXE to boot from the local disk, so you can leave all your machines with network booting enabled. After 10 seconds (or however many 1/10th of a second you specify as a timeout) it automatically chooses whatever label is specified in “ONTIMEOUT”. For most people, Local Disk is best, but if you have some sort of network bootable OS, you’d want to change it to that.

Now is a good time to make note of the IP of your TFTP server, and perhaps give it a static entry in your DHCP server.
For those COMPLETELY new to Linux, the command is:


The TFTP side is finished, so it’s time to setup routers.
As I mentioned, consumer routers don’t have this capability. Some of the better consumer routers that support 3rd party firmwares MAY have this capability, but I cannot guarantee it.
Since I it’s my article, I’m only listing instructions for DH Stamp-of-Approval equipment.
So here’s Mikrotik and pfSense:

Login to your router. Assuming the firmware is up to date enough, just use webfig. Otherwise you’ll have to Winbox.

http://[URL of Mikrotik]/webfig/#IP:DHCP_Server.Networks.1

(If that link doesn’t work, login to Winbox/WebFig -> IP -> DHCP Server -> Networks -> [Double Click First Network]

Set “Next Server” and “Boot File Name” to look like this:

pfSense 2.0:
Log into pfSense.

https://[IP of pfSense]/services_dhcp.php

If that doesn’t work, it’s under Services -> DHCP Server

Scroll down to network booting. Change it to look like this:

That’s pretty much it. Obviously this is only the beginning, since the only thing it currently does is ask you if you want to boot from the local disk. Part 2 will include entries for booting various network tools and how to boot ISOs. Windows will have to wait til Part 3 as they’re always 1000x more complicated than it needs to be.

© 2012 The Mind of DH Suffusion theme by Sayontan Sinha