How To Configure PXE Boot on CentOS 5

The other day I blogged about how to extract the kernel and ramdisk from the DBAN downloadable image.  These two files would be useful in the situation where you might want to PXE (network) boot a machine and have it wiped.  (Something like this may be common prior to dispositioning a machine at work, or before you give an old machine away.)  Whatever your reasons might be, I thought I would outline the steps that I have taken to install and configure PXE on a CentOS 5 installation.

Installation

yum install tftp-server

DBAN Configuration

After following my previous instructions on how to extract the DBAN PXE images, copy the two files (kernel.bzi and initrd.gz) to the /tftpboot/ directory.

mkdir -p /tftpboot/dban
cp kernel.bzi /tftpboot/
cp initrd.gz /tftpboot/

PXE Configuration

You’ll also need to configure the PXE system to know what to launch/run when a specific command is given at boot.  In this case we’ll only have the DBAN option, which we could run by using the ‘dban’ command:

/tftpboot/pxelinux.cfg/default

display msgs/boot.msg
prompt 1
## dban
label dban
kernel dban/kernel.bzi
append load_ramdisk=1 initrd=dban/initrd.gz root=/dev/ram0 init=/rc quiet nuke=”dwipe” –autonuke –method dodshort”

The first line in that file, “display” tells it to display a file as a menu prompt at boot time.  The second step in this section is creating that menu prompt:

/tftpboot/msgs/boot.msg

**WARNING** TYPE ‘dban’ TO AUTO-WIPE THE PXE BOOTED MACHINE.  **WARNING**

Start The Service

Now that we have everything configured we’ll go ahead and start the service:

service xinetd restart

DBAN via PXE: Automagically Wipe a Drive via Network Boot

One of my first assignments when I signed on with my new job was to rebuild and improve the internal repository server.  When I started it was quite a mess!  It only mirrored the last two revisions of Red Hat Enterprise, and didn’t have a whole lot of functionality.  Now that I’m done it supports Red Hat 3-5, both i386 and x86_64 as well as the respective CentOS releases.  It mirrors Ubuntu, Fedora, openSUSE and I added a few little tricks to the PXE server which allows us to build or destroy machines without needing to burn a CD.  One of the features that I really like is the addition of DBAN to the PXE setup, allowing us to securely wipe drives on multiple machines without the need for any CDs or other boot media.  Here is how I went about it:

Create Required Directories

mkdir /tftpboot/dban/

Download Latest Dban

wget -c http://prdownloads.sourceforge.net/dban/dban-1.0.7_i386.iso

Extract Dban Kernel and Initrd

mount -o loop dban-1.0.7_i386.iso /mnt/
cp /mnt/dban_1_0_7_i386.ima ~
mount -o loop ~/dban_1_0_7_i386.ima /mnt/
cp /mnt/{initrd.gz,kernel.bzi} /tftpboot/dban/
umount /mnt/ && umount /mnt/

These instructions don’t outline how to actually setup the PXE functionality, but simply go over how to extract the required kernel and ramdisk image which will allow for network booting. It would be nice if the DBAN site would offer something like this directly, but until then its not much more work.  I’ll do another post soon on how to setup the actual PXE server and configure it to use this newly extracted kernel and ramdisk.