Setting Up Debian PXE Server

Categories

Syndicate

Syndicate content

icon watch video

The Preboot eXecution Environment (PXE, aka Pre-Execution Environment, or 'pixie') is an environment to boot computers using a network interface independently of available data storage devices (like hard disks, CD Drives) or installed operating systems.
This method of installing OS can be very usefull when you want to deploy several os at ones or your machine does not support booting from a USB floppy or CD-ROM drive.

Packages requirements:
1. tftpd-hpa
2. dhcp3-server

1. Install neccasary packages:
# apt-get install dhcp3-server tftpd-hpa

2. Configure dhcp server:
Backup original dhcp.conf file before you edit it.
#mv /etc/dhcp3/dhcp.conf /etc/dhcp3/dhcp.conf-backup
Create and edit new dhcp.conf file and add the following lines, change these parameters to suit your network.

option domain-name-servers 192.168.248.2, 192.168.248.254;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.248.0 netmask 255.255.255.0 {
range 192.168.248.10 192.168.0.40;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.168.245.254;
filename "pxelinux.0";
next-server 192.168.248.100;
}
next-server  , this is your tftp server ip address.

restart your dhcp server.
# etc/init.d/dhcp3-server restart
2. Configure tftpd server:
Check if dhcpd and tftpd are running, dhcp server should be listening on udp port 67 and tftp on udp port 69 also make sure you open these ports if your firewall is on.
# netstat -anu

Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 0.0.0.0:1025            0.0.0.0:*
udp        0      0 0.0.0.0:1026            0.0.0.0:*
udp        0      0 0.0.0.0:67               0.0.0.0:*
udp 0 0 0.0.0.0:69 0.0.0.0:* udp 0 0 0.0.0.0:111 0.0.0.0:* udp 0 0 0.0.0.0:631 0.0.0.0:*

3. Create directory structure for all the distrubution you want to install, in our case we are install debian etch and ubuntu 7.10.

/var/lib/tftpboot
|
/ubuntu/10.7
|
|          /i386
|
|
/debian/etch
|
/i386

#mkdir -p /var/lib/tftpboot/debian/etch/i386

#mkdir -p /var/lib/tftpboot/ubuntu/10.7/i386

4. Download and add Debian Etch Netboot into var/lib/tftpboot/debian/etch/i386
# cd /var/lib/tftpboot/debian/etch/i386

# wget http://ftp.de.debian.org/debian/dists/etch/main/installer-i386/current/i...
# wget http://ftp.de.debian.org/debian/dists/etch/main/installer-i386/current/i...

5. Download and add Ubuntu Gutsy Netboot into var/lib/tftpboot/ubuntu/10.7/i386
# cd /var/lib/tftpboot/ubuntu/10.7/i386

# wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current...
# wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current...

6. PXELINUX – a second-stage boot-loader.

To set up PXELINUX, put the pxelinux.0 file (the boot-loader executable) in the /tftpboot directory in your TFTP server directory. PXELINUX also needs a configuration file. The config files are kept in the pxelinux.cfg directory
download pxelinux.0 bootloader and put it in /var/lib/tftpboot

# wget http://ftp.de.debian.org/debian/dists/etch/main/installer-i386/current/i... 

create pxelinux.cfg directory:

# mkdir /var/lib/tftpboot/pxelinux.cfg
7. edit pxelinux/cfg/default file

DISPLAY boot.txt
DEFAULT ubuntu_10.7
LABEL ubuntu_10.7
kernel ubuntu/10.7/i386/linux
append vga=normal initrd=ubuntu/10.7/i386/initrd.gz ramdisk_size=16417 root=/dev/ram rw  --
LABEL debian_etch
kernel debian/etch/i386/linux
append vga=normal initrd=debian/etch/i386/initrd.gz  --
PROMPT 1
TIMEOUT 0

8. Create boot.txt and add boot options.

Available Boot Options:
=======================
ubuntu_10.7
debian_etch

9. Done, your directory structure should look like this:

var/lib/tftpboot
|
/pxelinux.cfg
|
default
pxelinux.0
/ubuntu/10.7
|
/i386
|
initrd.gz
linux
|
/debian/etch
|
/i386
|
initrd.gz
linux
Tags
Comments

oldcheck, the boot.txt should be placed in var/lib/tftpboot folder, the second question, i'm not really sure, i will look into it and update this article.

Dear Shirwa,

first of all, thanks for this great arcticle.
I followed your how to and everything works fine, only the boot.txt isn't displayed.
I guess that I should've put it somewhere else then .../pxelinux.cfg/boot.txt but if so, where should I place it?

Another question is how can I offer the install sources via NFS or HTTP or FTP like
in redhat? Are there any differents?

Thanks and Regards

odcheck

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options