Setting Up A PXE Install Server For Multiple Linux Distributions With Ubuntu Edgy Eft

Version 1.0
Author: Falko Timme
Last edited 12/15/2006

This tutorial shows how to set up a PXE (short for preboot execution environment) install server with Ubuntu 6.10 (Edgy Eft). A PXE install server allows your client computers to boot and install a Linux distribution over the network, without the need of burning Linux iso images onto a CD/DVD, boot floppy images, etc. This is handy if your client computers don't have CD or floppy drives, or if you want to set up multiple computers at the same time (e.g. in a large enterprise), or simply because you want to save the money for the CDs/DVDs. In this article I show how to configure a PXE server that allows you to boot multiple distributions: Ubuntu Edgy/Dapper, Debian Etch/Sarge, Fedora Core 6, CentOS 4.4, OpenSuSE 10.2, and Mandriva 2007.

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

It is important that you have a decent internet connection because your client computers will fetch all needed packages from the repositories in the internet (I tested this on a 16MBit ADSL2+ connection which seems to be fast enough. ;-)). It is possible to store all packages on the PXE server as well so that you don't need an internet connection (just the LAN connection to the PXE server), but then you need a lot of storage space on the PXE server (remember, it will serve multiple distributions), so I don't cover this here.

And the most important thing is that your client computers support booting over the network. You should check each computer's BIOS for this option.

On our system that should serve as the PXE server you should have already set up a basic Ubuntu 6.10 server system, for example as shown on pages 1 - 3 of this tutorial: http://www.howtoforge.com/perfect_setup_ubuntu_6.10

I prefer to do all the steps here as the root user. So if you haven't already created a root login, you should do so now:

sudo passwd root

Afterwards, log in as root:

su

If you would like to work as a normal user instead of root, remember to put sudo in front of all the commands shown in this tutorial. So when I run

apt-get update

you should run

sudo apt-get update

instead, etc.

 

2 Install All Necessary Packages

First we update our packages database by running

apt-get update

We need to install the packages netkit-inetd, tftpd-hpa, dhcp3-server, and lftp, so we run

apt-get install netkit-inetd tftpd-hpa dhcp3-server lftp

Afterwards run

netstat -uap

and check if you see something like this:

root@server1:~# netstat -uap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 *:tftp

If you don't see the tftp line, please open /etc/inetd.conf and make sure you find the following in it:

vi /etc/inetd.conf

[...]
#:BOOT: Tftp service is provided primarily for booting.  Most sites
# run this only on machines acting as "boot servers."
tftp           dgram   udp     wait    root  /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
[...]

Then restart inetd:

/etc/init.d/inetd restart

 

3 Configure The DHCP Server

We need a DHCP server in our local network. If there's no DHCP server in your local network, just configure and use the one on your future PXE server. Simply edit /etc/dhcp3/dhcpd.conf:

cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_orig
cat /dev/null > /etc/dhcp3/dhcpd.conf

vi /etc/dhcp3/dhcpd.conf

option domain-name-servers 145.253.2.75, 193.174.32.18;

default-lease-time 86400;
max-lease-time 604800;

authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.49;
        filename "pxelinux.0";
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.0.255;
        option routers 192.168.0.1;
}

This will dynamically assign IP addresses from the range 192.168.0.10 to 192.168.0.49 to your client computers; the gateway is 192.168.0.1. Of course, you must adjust this configuration to your own environment!

It is important that you have the line

filename "pxelinux.0";

in your configuration!

Then restart your DHCP server:

/etc/init.d/dhcp3-server restart

If you already have a DHCP server in your network, you must modify its configuration. Let's assume you have something like

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.49;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.0.255;
        option routers 192.168.0.1;
}

in the configuration. You must add

filename "pxelinux.0";
next-server 192.168.0.100;

to it (where 192.168.0.100 is the IP address of our Ubuntu PXE server) so that it looks like this:

subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.10 192.168.0.49;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.0.255;
        option routers 192.168.0.1;
        filename "pxelinux.0";
        next-server 192.168.0.100;
}

Then restart your DHCP server.

Share this page:

13 Comment(s)

Add comment

Comments

From: Wim at: 2009-02-16 09:29:19

Running "sudo su - " gives you a root prompt, after typing your own password.

From: Michael Boman at: 2012-01-09 16:05:14

sudo -s

does the same thing. On some distributions may you want to do

sudo -i

instead.

From: Anonymous at: 2009-06-15 11:19:58

There is no /etc/init.d/inetd in Ubuntu 8.04.2 LTS to fix this do

 /etc/init.d/openbsd-inetd restart

 

From: at: 2007-03-18 23:57:08

First I'd like to thank you for a very useful and informative article. This has certainly helped me to get PXE set up on Linux much faster than figuring it all out myself. :)

One thing I'd like to point out is that if you intend on using PXE to deploy an OS to the hard disk of the target computers it is much easier and safer to simply press F12 during POST then muck about with the BIOS settings. F12 should make the machine perform a once-off network boot and saves a huge amount of time when deploying to multiple machines as no other configuration is required. This has long been the standard procedure for 'big-brand' corporate desktop PCs and has been adopted by most white box manufacturers as well.

From: at: 2006-12-19 13:49:18

Very nice tutorial falko, as always.

If you use this often, or if you have a large environment to maintain with a lot of servers, it might be a good idea to create a separate VLAN for the PXE stuff (Installation VLAN). That way, your live servers won't be affected when their BIOS settings are faulty.
You will have to alter the network settings or switch port after the installation has finished of course.

It is probably best to mirror the OS repositories on the PXE boot server as well, to limit bandwidth usage, not just for yourself but also for the server you download it off, and to speed up the install process. This is especially beneficial if you have to install a few servers at once. Like falko said, you will need a lot of free diskspace if you want to serve several different flavours.
When you have a local OS repository, it is also possible to tweak certain files a bit before they are used in the new installation. Things like site wide defaults and global config options etc.

From: marco at: 2010-08-19 09:04:31

Same question of banksps. Is possible to deploy windows server also?

From: at: 2006-12-20 16:37:32

I recommend the following changes in dhcpd configuration

deny unknown-clients;

as a global parameter and a

host server1 {  hardware ethernet 00:11:22:33:44:55; }

per server on the range section.

This will allow you to use another DHCP server on the same VLAN. Even if you don't have another DHCP server, this will allow you to have more control over who want to install a server via PXE.

From: at: 2006-12-20 21:18:36

Thanks a lot for this howto. It worked perfectly for me and I never even knew that something like this could be done!

From: at: 2007-09-06 12:06:08

I almost hate to ask because I'm such a Linux fanatic but I do end up having to re-install Windows systems.  Does anybody know of a way to use PXE for a Windows install?  I did some similar PXE work and I love it.  Find mine at: http://blog.banksnetworking.com/2007/08/28/pxe-for-the-masses/

 

From: at: 2008-04-18 22:00:52

On SLES (and I assume OpenSUSE) there is an install= kernel parameter where you can tell the installer where to grab the install media. It supports http and nfs and probably more.

kernel sles.kernel
append install=http://server/SLES (other options ommited)

When the installer starts it will not prompt you for the CDs any more. As a side note, there are tutorials out there on how to convert all the install CDs to a single directory tree so you can share it out.

From: Anonymous at: 2010-04-09 16:10:10

Nice recipe for setting up the DHCP + PXE end of the scheme. Would really like to see a tutorial for the next logical phase, which would be how to create local copies of the installation data. Being able to serve complete installations without leaving the LAN seems like a very good way to conserve bandwidth, but that requires setting up local mirrors/repositories/whatever-they're-calleds for each distro. My experience trying to do this for Debian Lenny has so far not worked well, and an explanation that includes a clear recipe such as this one would be most welcome.

Keep up the Good Work.

  
 

From: Anonymous at: 2010-10-01 04:44:34

can it possible to do unattend unstallation for windows operating system(xp,vista, win7) using same ubuntu PXE server

From: Leopoldo at: 2013-03-09 21:38:02

Hi. How should I set for the case to have an OpenSuse image made ??with Clonezilla, and use it to network nodes use it, I meen do not use "installers" but existing machine images. Thanks for the input, has served me well.