[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

PXE Server Setup

1. Introduction

1.1. About

This document intends to describe the process of extending an existing CentOS system to support PXE booting of other machines. It includes a simple DHCPd configuration. When complete, a system configured for booting from the network using PXE should be able to get needed files.

1.2. Prerequisites

2. TFTP Server Setup

TFTP (Wikipedia:Trivial File Transfer Protocol) is a simple way to transfer small amounts of semi-public data, like boot images, without authentication.

2.1. Install TFTP

yum install tftp-server

2.2. Enable TFTP

Edit /etc/xinetd.d/tftp and change disable to 'no'.

disable = no

2.3. Restart xinetd

xinetd handles TFTP connection attempts. It reads configuration files when starting.

service xinetd restart

3. Setup Boot images

For each system combination, there are going to be several files required to boot.

3.1. Create Image Directories

Using a directory to segregate the OS boot images keeps /tftpboot/ clean and might make it easier to find things later. Some would use the plural images while others would use the singular image.

To maintain original file names, a directory for each combination of system (OS, arch and release) is recommended. The option -p creates any missing parent directories. The order isn't necessarily important. Some would argue $ARCH is more significant, others would argue for $RELEASE.

mkdir -p /tftpboot/images/centos/i386/3.0
mkdir -p /tftpboot/images/centos/i386/3.1
mkdir -p /tftpboot/images/centos/x86_64/3.0
mkdir -p /tftpboot/images/centos/x86_64/3.1
mkdir -p /tftpboot/images/centos/i386/4.0
mkdir -p /tftpboot/images/centos/i386/4.1
mkdir -p /tftpboot/images/centos/x86_64/4.0
mkdir -p /tftpboot/images/centos/x86_64/4.1
mkdir -p /tftpboot/images/centos/i386/5.0
mkdir -p /tftpboot/images/centos/i386/5.1
mkdir -p /tftpboot/images/centos/x86_64/5.0
mkdir -p /tftpboot/images/centos/x86_64/5.1

or

OS="centos"
for RELEASE in "3.0" "3.1" "4.0" "4.1" "5.0" "5.1" ; do
  for ARCH in i386 x86_64 ; do
    mkdir -p /tftpboot/image/${OS}/${RELEASE}/${ARCH}
  done
done

For a Xen VM, it could be ...

OS="centos"
RELEASE="5.3"
ARCH="i386-xen"
mkdir -p /tftpboot/image/${OS}/${RELEASE}/${ARCH}

3.2. Copy CentOS Boot Files

For each "Release" and "ARCH", copy vmlinuz and initrd.img from /images/pxeboot/ on "disc 1" of that $RELEASE/$ARCH to /tftpboot/images/centos/$ARCH/$RELEASE. The Xen boot files are in /images/xen.

4. DHCPd

DHCP (Wikipedia:Dynamic Host Configuration Protocol) is used to tell the machines on the network what their address is and provides information about how to interact with other machines.

4.1. Configure DHCPd

Add this to your existing or new /etc/dhcpd.conf.

Note: xxx.xxx.xxx.xxx is the IP address of your PXE server

allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server xxx.xxx.xxx.xxx; 
filename "/pxelinux.0";

4.2. Restart DHCPd

service dhcpd restart

Syslinux (The Syslinux Project) is a bootloader. It can be used on CD/DVD's, PXE boots, DOS FAT partitions and others to provide boot assistance, including menus.

5.1. Install Syslinux

The version of syslinux that is installed as part of the base system is out-dated. There is a newer version on RPMForge. Assuming that repository is available, installing the updated version of syslinux is as easy as:

yum install syslinux

5.2. Copy Needed Files

A simple setup would be to copy syslinux files to /tftpboot/

cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /usr/lib/syslinux/menu.c32 /tftpboot
cp /usr/lib/syslinux/memdisk /tftpboot
cp /usr/lib/syslinux/mboot.c32 /tftpboot
cp /usr/lib/syslinux/chain.c32 /tftpboot

If the intent is to serve other things through TFTP, you could put the modules into a subdirectory to keep /tftpboot/ relatively clean. Including memtest could allow for testing the memory in a machine easily.

cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
mkdir /tftpboot/pxe-mod
cp /usr/lib/syslinux/menu.c32 /tftpboot/pxe-mod/
cp /usr/lib/syslinux/memdisk /tftpboot/pxe-mod/
cp /usr/lib/syslinux/mboot.c32 /tftpboot/pxe-mod/
cp /usr/lib/syslinux/chain.c32 /tftpboot/pxe-mod/
cp /usr/lib/syslinux/memtest /tftpboot/pxe-mod/

Just remember that if you put the modules in a subdirectory, any place you refer to them in the future would include that directory. I.E. instead of menu.c32, use pxe-mod/menu.c32.

5.3. Create Directory for PXE menus

PXELinux expects to find its configuration files in a subdirectory, pxelinux.cfg.

mkdir /tftpboot/pxelinux.cfg

5.4. Create Menu

When booting, PXELinux looks for a series of files, but falls back to pxelinux.cfg/default. A very simple default file could be.

DEFAULT linux
PROMPT 100

LABEL linux
  KERNEL images/centos/5.3/i386/vmlinuz
  APPEND initrd=images/centos/5.3/i386/initrd.img

For more information about setting up PXE Menus, see Setup simple or multilevel PXE Menus

For more information about kickstart files and setting up automated installations, see CentOS 5 Documentation Installation Guide Advanced Installation and Deployment


2023-09-11 07:19