Ubuntu Documentation
This tutorial shows how to set up a PXE (short for pre-boot execution environment) install server with Ubuntu 9.10 (Karmic Koala).
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, Debian, Fedora, CentOS, and openSUSE.
The end result will be a network boot-able menu with sub-menus allowing you to choose an OS to install/boot:
Required
- TFTP Server
- Syslinux
- DHCP Server
- NFS Server
- PXE capable NICs
If you intend on installing Ubuntu via PXE/HTTP, I highly recommend apt-mirror is installed to provide a local repository of Ubuntu packages and Apache is installed to serve those packages via HTTP.
BIND will allow the DHCP server to assign host names to the PXE clients. This article will not cover the installation and configuration of BIND, however to assign dynamic names to DHCP clients I have the following in my zone files:
Getting Started
Install Ubuntu 9.10 (Karmic Koala) on a system that you will use as the deployment server. I prefer a minimal install and then install required/optional packages as needed. Once your operating system is installed, update the system with the package manager of your choice.
These can be included in a single command: sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get clean (&& will run the next command only if the previous command succeeds)
Install prerequisite software
TFTP Server
Ubuntu installs the openbsd-inetd pakcage when the tfpd-hpa package is installed. In our example we will simply run TFTP as a daemon and will always be listening for connections.
In the above code snippet:
- tftpd-hpa was intsalled
- The openbsd-inetd daemon was stopped
- openbsd-inetd was removed from the startup scripts
- /etc/defaul/tftpd-hpa was modified to allow tftpd-hpa to run as a daemon process
- tftpd-hpa was started
Verify the TFTP server is listening for connections:
DHCP Server
If your network does not have a DHCP server, install the Internet Software Consortium’s DHCP server. With an existing DHCP server, you will need to modify the scope for your subnet to include the information allowing PXE clients to contact the TFTP server.
The scope of an existing DHCP server should be modified to reflect:
I will assume no DHCP server exists. We will install and configure one.
After installation the daemon will attempt to start, however, will fail since the default configuration file does not contain a valid DHCP scope for our subnet. The configuration file for dhcp3-server is /etc/dhcp3/dhcpd.conf. The file is well commented and easily modified to fit your subnet(s).
In the above configuration:
- Dynamic DNS Updates are disabled
- The DNS domain name is home.local
- The DNS server is 10.10.1.10 (this is also the TFTP and NFS server)
- The DHCP lease time is 1 day
- The log will include a time-offset of -18000 to more closely match the local time zone. The DHCP client leases can be viewed in /var/lib/dhcp3/dhcp.leases
- The DHCP server is authoritative for the network
- Booting is enabled, this does not imply PXE booting, however other documents will be written to support booting a file-system over NFS instead of a local disk.
- The DHCP scope of the subnet for 10.10.1.1 includes:
- A range of addresses to be assigned to DHCP client
- The location of the TFTP server
- The file to obtain from the DHCP server
- Various hosts are reserved IP addresses in order for them to always receive the same IP address via DHCP.
Start the DHCP server.
Verify the DHCP server is listening for client connections.
SYSLINUX
The SYSLINUX Project is a suite of lightweight boot-loaders, for starting up computers with the Linux kernel. It is the work of H. Peter Anvin, and consists of several separate systems, the best-known of which is ISOLINUX.
The PXELINUX bootstrap will be installed when syslinux is installed.
PXELINUX is used in conjunction with a PXE compliant ROM on a network card. The PXE environment uses DHCP or BOOTP to enable basic TCP/IP networking, then downloads a bootstrap program via TFTP. This bootstrap program loads and configures a kernel according to directives that are also downloaded from the TFTP server.
Typically, PXELINUX is used for Linux installations from a central network server or for booting disk-less workstations.
Copy the PXELINUX bootstrap to the root of our TFTP server.
Configuration files for PXELINUX reside in directory /var/lib/tftpboot/pxelinux.cfg/. PXELINUX uses the following method to search for the appropriate configuration file:
The hardware type (using its ARP type code) and address, all in lower case hexadecimal with dash separators; for example, for an Ethernet (ARP type 1) with address 88:99:AA:BB:CC:DD it would search for the file-name 01-88-99-aa-bb-cc-dd.
The client IP address in upper case hexadecimal, e.g. 192.0.2.91 -> C000025B
As an example, if the boot file name is pxelinux.0, the Ethernet MAC address is 88:99:AA:BB:CC:DD and the IP address 192.0.2.91, it will try following the files:
- /var/lib/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd
- /var/lib/tftpboot/pxelinux.cfg/C000025B
- /var/lib/tftpboot/pxelinux.cfg/C000025
- /var/lib/tftpboot/pxelinux.cfg/C00002
- /var/lib/tftpboot/pxelinux.cfg/C0000
- /var/lib/tftpboot/pxelinux.cfg/C000
- /var/lib/tftpboot/pxelinux.cfg/C00
- /var/lib/tftpboot/pxelinux.cfg/C0
- /var/lib/tftpboot/pxelinux.cfg/C
- /var/lib/tftpboot/pxelinux.cfg/default
Create the PXELINUX default configuration file.
There are two NFS servers for Ubuntu.
- nfs-user-server
- nfs-kernel-server
As the package name indicates, one runs in user space and the other in kernel space.
The NFS server uses /etc/exports to identify what local directories are available to NFS clients.
We will be using /srv/install and the NFS export to store operating system files used for installation.
Modify /etc/exports and make /srv/install available for our Linux installations.
The above configuration will allow read-only access via NFS to /srv/install/ for clients on the 10.10.1.0 network.
Export our file system or restart the NFS server.
Putting it All Together
We have installed:
- TFTP Server
- SYSLINUX
- NFS Server
- DHCP Server
Let’s start our first install with Fedora 10 64-bit. You will need to make the kernel and initrd available via TFTP, and the installation media available via NFS.
Choose a directory structure that will allow you to maintain multiple distributions.
To store the kernel and initrd:
To store the installation media:
Fedora
Create the directories to store Fedora 10.
Mount the Fedora 12 64-bit DVD ISO and copy the kernel and initrd to the previously created location.
Mount the Fedora 12 32-bit DVD ISO and copy the kernel and initrd to the previously created location.
Many options exist for PXELINUX. You can have:
- No menu
- An abysmal black screen with text
- A menu
- An advanced menu that supports nested menus
- A graphical menu
Since we want a nice pretty menu that contains sub-menus and a background image, we will need vesamenu.c32 from the SYSLINUX installation and our background image. (logo.png)
Modify our PXELINUX configuration file.
An explantion of the example /var/lib/tftpboot/pxelinux.cfg/default:
- DEFAULT vesamenu.c32 — We are informing PXELINUX to load this file. We could substitute a menu entry instead, or boot a kernel and initrd.
- TIMEOUT 600 — 600 seconds will pass before action is taken on the users behalf if no keys are pressed
ONTIMEOUT — Indicates what action is performed when the TIMEOUT expires. In the above example, we are loading the menu item BootLocal. If after 5 minutes the user does not choose a menu item, the system will attempt to boot to a local hard disk.
The above pxe.conf file is configuring
- The colors used
- The width
- The number of items displayed
- The backgroud image
As we are using Fedora 10 as our first example operating system, the following is the Fedora menu.
Create the Fedora menu.
The above menu entry for Fedora 12 informs the client:
- Which kernel to load
- The location of the installation media
- The language used during the installation
- The keyboard map used during the installation
- Obtain an IP address using DHCP
- Use eth0 to install the operating system in case there are multiple NICs
- Disable IPv6
- Which initrd to use
- The ram disk size used during the install
This does not prevent every installation question from being asked. You will still be prompted for:
- Disk partitioning scheme
- Package selection
- User account information
- Etc.
You can completely automate the installation using a kickstart file, however, this article will not cover its usage.
When a client now boots via PXE, the client will:
- Request an IP address
- The server will assign an IP address and inform the client which bootloader to use i.e pxelinux.0.
- The Client will download pxelinux.0 via TFTP
- pxelinux.0 will load vesamenu.c32
- The graphical menu will be displayed on the screen.
- Once the user navigates to the Fedora menu and chooses the version to install:
- The kernel and initrd will be downloaded via TFTP
- Control will be handed over to the kernel
- Mount the NFS export and the installation process will begin.
openSUSE
Next, we will follow the same procedure and configure support for openSUSE to be installed.
Create the directories to store openSUSE 11.2.
Mount the openSUSE 11.2 64-bit DVD ISO and copy the kernel and initrd to the previously created location.
Mount the openSUSE 11.2 32-bit DVD ISO and copy the kernel and initrd to the previously created location.
Create the openSUSE menu.
Once again, this does not prevent every installation question from being asked. This article does not cover automated installations for openSUSE.
CentOS
Again we will follow the same procedure and configure support for CentOS to be installed.
Create the directories to store CentOS 5.4.
Mount the CentOS 5.4 64-bit DVD ISO and copy the kernel and initrd to the previously created location.
Mount the CentOS 5.4 32-bit DVD ISO and copy the kernel and initrd to the previously created location.
Create the CentOS menu.
Ubuntu
We will now configure support for Ubuntu to be installed.
There are multiple methods to install Ubuntu over the network, however, we will simply boot the Ubuntu Live CD over the network.
For an unattended method for installing Ubuntu over the network, please reference AutomatedNodeDeployment.
Create the directories to store the Ubuntu 9.10 CD.
Mount the Ubuntu 9.10 Desktop 64-bit DVD ISO and copy the kernel and initrd to the previously created location (starting around 10.04 a .disk directory on the Ubuntu ISO’s are necessary to complete booting, be sure to copy that over as well or booting will freeze).
Mount the Ubuntu 9.10 Desktop 32-bit DVD ISO and copy the kernel and initrd to the previously created location (starting around 10.04 a .disk directory on the Ubuntu ISO’s are necessary to complete booting, be sure to copy that over as well or booting will freeze).
Create the Ubuntu menu.
The boot process may appear to halt at «squashfs: version 3.3 (2007/10/31)Phillip Lougher».
Press Alt+Enter and the initialization will resume.
To support booting DOS via PXE, we will use MEMDISK.
MEMDISK is meant to allow booting legacy operating systems via PXE, and as a workaround for BIOSes where ISOLINUX image support doesn’t work.
MEMDISK simulates a disk by claiming a chunk of high memory for the disk and a (very small — 2K typical) chunk of low (DOS) memory for the driver itself, then hooking the INT 13h (disk driver) and INT 15h (memory query) BIOS interrupts.
MEMDISK is an auxillary module used in conjunction with one of the SYSLINUX bootloaders, usually PXELINUX or ISOLINUX. You need a disk image as well as the memdisk file itself. As far as the bootloader is concerned, memdisk is the «kernel» and disk image is the initial ramdisk (initrd).
Copy the MEMDISK module to the root of your TFTP server.
Create the directory to store DOS.
Obtain a MS-DOS bootable floppy disk and create an image from the floppy.
Create the DOS menu.
The ability to boot DOS via PXE can be extremely useful. You can create a DOS based floppy to flash firmware, or run a multitude of tools.
Utilities
The last example in this article will be booting other utilities via PXE.
Darik’s Boot and Nuke («DBAN») is a self-contained boot disk that securely wipes the hard disks of most computers. DBAN will automatically and completely delete the contents of any hard disk that it can detect, which makes it an appropriate utility for bulk or emergency data destruction.
Create the directories to store DBAN 2.0.
Mount the DBAN 2.0 CD and copy the kernel to the previously created location.
Create the utilities menu.
Summary
We have covered the configuration of a system that will allow multiple operating systems to be booted or installed via PXE and some using both PXE and NFS. Many more possibilites exit such as booting:
- SLAX
- Parted Magic
- Knoppix
- xPUD
- VMWare
- openFiler
- RHEL
- etc.
It is also possible to PXE boot the Microsoft Windows installer and make the installation files available using Samba. This process was not covered, however you can review the process at http://oss.netfarm.it/guides/ris-linux.php
Troubleshooting
Boot failed: press a key to retry, or wait for reset.
A configuration file was not found and the boot process halts with this error. Check your config file(s). Otherwise, a configuration file is located and the commands within it will be executed (e.g. a boot menu will be displayed and the default option executed when selected).
PXEInstallMultiDistro (последним исправлял пользователь zeroedout 2013-06-25 04:13:32)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник