pantz.org banner
How to make SystemRescueCD PXE bootable
Posted on 05-29-2008 16:07:32 UTC | Updated on 05-29-2008 16:18:28 UTC
Section: /software/pxe/ | Permanent Link

Have you ever wanted to stop carrying those bootable floppy disks, cd-rom's, or usb drives everytime you want to install, test, update, or rescue a machine on your network? If you have a network with hundreds or thousands of computers it's a pain to be lugging usb drives or cd-rom's to boot one if they need a new disk image or to test a hardware problem. Enter PXE. PXE, aka Pre-Execution Environment, or 'pixie' is an environment used to boot computers using a network interface. That means you need no data storage device at all to boot the machine. Most current machines have settings in the bios to turn on PXE booting. With PXE booting you can do things like booting dos floppy image with bios update or run a memory test with memtest86. You can also boot full operating systems to rescue or burn in machines. The following information will show you how to setup the enviorment to PXE boot the linux distro SystemRescueCD and some other boot images. This example is done using CentOS. Let's get started.

First we have to turn on PXE booting for each machine. Boot the computer and go into the bios. Find the section in the bios that has to do with the boards devices. There will usually be a section about the LAN or ethernet devices. It will say something like "OnBoard LAN Boot ROM". Turn this on. Save the settings. Reboot. Go back into the bios and find the boot device section. Here you will select the order of your boot devices. Your network controller should be in the list of devices. It might be called something funny like "IBA GE Slot ..." but rest assured that is the LAN adapter. Move it up or down in the order you want to have it try to boot the machine over the network. It has to be before a device that has boot media or it will boot that device first.

Now we need to add a few lines to your dhcp server. If you don't have one you will need to set one up as PXE can not work without one. If your using CentOS you can install one with the command "yum install dhcp". On a working dhcpd server you will need to add the following lines to the /etc/dhcpd.conf configuration file. Make sure you choose your own ip blocks for the different ranges here. Restart the dhcpd server after putting in the lines.

subnet 192.168.5.0 netmask 255.255.255.0
{
range 192.168.1.50 192.168.1.55;
range dynamic-bootp 192.168.1.56 192.168.1.60;
next-server 192.168.5.1;
filename "pxelinux.0";
}

If your dhcpd.conf file already has the subnet line then you just need following lines in between the curly braces. Make sure you choose your own ip blocks for different ranges here. The dynamic-bootp line is the ip range for the PXE boot servers. Choose an empty range on your network for these ip's. The next-server line should be the tftp server ip address (which we will setup next). The filename line is the file that is given out on boot.

range dynamic-bootp 192.168.1.56 192.168.1.60;
next-server 192.168.5.1;
filename "pxelinux.0";

On the same machine or another machine you will need to start a tftp server. PXE will not work without this either. You can install one on CentOS machines with the command "yum install tftp-server". After it's installed we will make a few dir's we need and start the server. The commands for this are below.

mkdir /tftpboot
mkdir -p /tftpboot/pxelinux.cfg
/usr/sbin/in.tftpd -l -B 1460 -s /tftpboot/

Now make sure the syslinux package is installed on the machine with the tftp server. Syslinux is the boot loader PXE will use to boot. You can install it on CentOS using the command "yum install syslinux". Then find out where the file pxelinux.0 lives. On my install it was in /usr/lib/syslinux/pxelinux.0. Copy this file to the /tftpboot dir.

cp /usr/lib/syslinux/pxelinux.0 /tftpboot

Download the latest SystemRescueCd iso to the machine with the tftp server. We are going to mount it on loopback so we can pull some files off to put in the /tftpboot dir. Don't use any version of SystemRescueCD prior to 1.0 for PXE booting. It's broken. This example uses version 1.0.

mkdir /tmp/iso
mount -o loop systemrescuecd-x86-1.0.0.iso /tmp/iso
cd /tmp/iso
cp bootdisk/* /tftpboot
cp isolinux/* /tftpboot
cp syslinux/syslinux.cfg /tftpboot/pxelinux.cfg/default

Now we need to setup an http server. Apache, thttpd, lighttpd, or any other http server will do. I would suggest thttpd if you just want to setup a simple http server. The reason for this is that we need to pull the root filesystem over on boot and it's over 150MB. Doing that via tftp is super slow. Tftp was not made for large files. sysrcd.md5 and sysrcd.dat are the 2 files that need to be copied to the http server running on the machine you installed tftp or any other http server you have running already. It does not have to be on this machine. Only these 2 files are transfered this way. The rest are done via tftp. My example will show copying the 2 files to a dir on the same machine as the tftp server. The root of the my http server will be pointing to /var/www/htdocs/.

cp /tftpboot/sysrcd.md5 /tftpboot/sysrcd.sys /var/www/htdocs/systemrescuecd

Let's modify the default SystemRescueCD menu file /tftpboot/pxelinux.cfg/default. You will need to modify the 2nd line in the file which is the kernel options line for the default kernel (rescuecd). The line starts with the word append. Append the following line (below) to the end of the append line.They are just boot options for the kernel. This will need to go after each line in the default file you want to boot from that needs the SystemRescueCD root filesystem. Other boot images like memtest won't need it. If you put your sysrcd.dat file on a different http server or path from example configuration above then you will need to edit the boot line to reflect where that file is.

setkmap=us boothttp=http://192.168.5.1/systemrescuecd/sysrcd.dat dodhcp ar_source=http://192.168.5.1/systemrescuecd/ ar_nowait

The first sets the keymap to US. The second tells rescue cd to get the root filesystem from an http server (tftp is very slow ~2MB/s). You can also replace boothttp=http with boottftp=tftp. I can't stress enough that tftp is to slow for big images like sysrcd.dat. The dodhcp says to make a dhcp request after booting. The line starting with ar_source tells the system to pull a shell script off an server and execute it after booting. The file it pulls has to be named autorun and it has to be a shell script. You can have 10 autorun files. The format is autorun#. Where # is a digit from 0 to 9. ar_nowait tells the machine to not wait for a keypress after executing server. Take out the ar_source part if you don't want to execute an autorun shell script after boot. It is not required. Save this file after your done editing.

If you do what to use the autorun script then here is an idea for it. Put some files you might need when you boot your enviorment in a dir and have ncftpget or wget (already on the SystemRescueCD cd) get any files for you after boot. Make a dir in the same dir you have your SystemRescueCD boot files and put your files in there. Then on boot it will pull those files over for you to use. For example I have an ftp server I pull files from when my image boots. The example is below.

#!/bin/bash
ncftpget ftp://192.168.5.6/systemrescuecd/scripts/*.sh
ncftpget ftp://192.168.5.6/seatools/st
chmod 755 *.sh st

That should be it. Boot a machine (with PXE turned on) that has network access to all the things we setup. It should boot. PXE will get an ip from the dhcp server (bootp) and then pull the pxelinux.0 file (via tftp) to boot. After the pxelinux.0 file is loaded it should bring up the SystemRescueCD menu and you can boot from there. You will notice if you hit the F2 key you will get other menu items. You can boot these other images also. SystemRescueCD comes with boot images like memtest for memory testing or dban for disk wiping.

Del.icio.us! | Digg Me! | Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib