Setting Up A Linux PXE Server and Integrating Clients: Howto
Setting Up A Linux PXE Server and Integrating Clients: Howto
HOWTO
Abstract.............................................................................................................................................. 2 Text conventions .................................................................................................................................. 2 Required hardware and software........................................................................................................... 2 For the PXE server ............................................................................................................................ 2 For the clients .................................................................................................................................. 2 Overview............................................................................................................................................ 3 pxelinux functionality ........................................................................................................................ 3 Kickstart files ................................................................................................................................... 4 Setting up the PXE server ...................................................................................................................... 4 Integrating the clients ........................................................................................................................... 7 Troubleshooting ................................................................................................................................. 10 Bootcfg usage information............................................................................................................... 10 Potential kickstart installation issues .................................................................................................. 10 Additional configuration for ProLiant BL10e servers ............................................................................ 11 Appendix a: glossary ......................................................................................................................... 13 Appendix b: sample scripts and files.................................................................................................... 14 For the PXE server .......................................................................................................................... 14 NFS configuration file ................................................................................................................. 14 syslinux.cfg files ......................................................................................................................... 14 import-to-tftpboot.sh file ............................................................................................................... 16 For the clients ................................................................................................................................ 17 dhcpd.conf script........................................................................................................................ 17 syslinux.cfg script ....................................................................................................................... 19 Kickstart file ............................................................................................................................... 19 For more information.......................................................................................................................... 21 Call to action .................................................................................................................................... 21
Abstract
This HOWTO describes how to set up a Red Hat Linux 8.0 Pre-boot eXecution Environment (PXE) server and how to integrate a Red Hat Linux 8.0 client with the PXE server. Additionally, this HOWTO explains how to use Linux images on a PXE server and how to configure a client for PXE.
Text conventions
This HOWTO uses the following conventions to distinguish elements of text:
Menu options, Command names, Dialog box names, and Screen names User input (commands to be typed) Scripts and files These elements appear in initial capital letters and may appear in boldface for emphasis. User input appears in a different typeface and is highlighted in gray. The content of the scripts and files appears in a different typeface and is highlighted in gray with a border around it. Boldface text should be located on one line instead of on multiple lines as shown in the samples; formatting in this document prohibits correct usage. Comments included in the scripts are listed in blue font for explanation purposes and marked with comment markers (#) so that the code can be copied and pasted.
Overview
This section presents an overview for using the pxelinux process and kickstart files.
pxelinux functionality
The pxelinux functionality occurs in this order: The client machine boots to PXE which requests a DHCP address. The DHCP server responds with an IP address for the client machine along with the address of a TFTP server and a filename to load (pxelinux.0) from that server. The client then downloads pxelinux.0 from the specified TFTP server and executes it. pxelinux.0 then searches the pxelinux.cfg directory on the server for a configuration file that matches the IP address of the machine. If no matches are found, it will attempt to load a file called default. The configuration file loaded by pxelinux.0 will have instructions on what to do next. Some of the choices include boot to local hard drive, boot to an image file (floppy image), or load vmlinuz and initrd.img. The client searches for a configuration file with the IP address converted to HEX (for example, 172.48.1.253 becomes AC3001FD). In this example, the client looks for the following configuration file names and uses the first one it finds.
AC3001FD AC3001F AC3001 AC300 AC30 AC3 AC A default
This process allows IP groups to be used. The examples in this paper use AC3001FD, the most specific choice.
Kickstart files
An automated installation of Red Hat Linux is performed through a process called kickstart. A kickstart file is a collection of instructions and keywords that the Red Hat Linux installer, called anaconda, uses to perform an unattended install. Often a kickstart file is created by using the program called redhat-config-kickstart or ksconfig which is used by older versions of Red Hat Linux. Anaconda also places a kickstart file in the /root directory upon installation completion.
Note For more information about anaconda, visit http://rhlinux.redhat.com/anaconda/.
A kickstart file, commonly labeled ks.cfg, may be placed in several locations so that anaconda can find it. These locations include being placed on an NFS server, FTP server, HTTP server, floppy, CDROM, or hard drive. The method described in this HOWTO places the ks.cfg file on an NFS server. The method described in this HOWTO assumes that the syslinux/pxelinux package will be used on Red Hat Linux 8.0 to allow the clients to boot to PXE.
Note Refer to the ProLiant server certification matrix, http://h18000.www1.hp.com/products/servers/linux/ hpLinuxcert.html, to determine a suitable server for Red Hat Linux 8.0.
3. Set up the date and time on the PXE server. 4. Set up the PXE server hostname.
After updating /etc/hosts, run the hostname command to change the hostname:
hostname pxe1.pxe.net
Edit the /etc/sysconfig/network as follows: Static: NETWORKING=yes HOSTNAME="pxe1.pxe.net" Dynamic: NETWORKING=yes HOSTNAME="pxe1.pxe.net" DHCP_HOSTNAME="pxe1.pxe.net"
A sample /etc/dhcpd.conf configuration file is located at /usr/share/doc/dhcp3.0pl1/dhcpd.conf.sample. Copy this sample to /etc/dhcpd.conf. If more than one network card resides in the DHCP server, HP recommends specifying which interfaces the DHCP server will use. Edit /etc/sysconfig/dhcpd by adding the appropriate interface to the DHCPDARGS= line. The entry in /etc/sysconfig/dhcpd should appear as follows: DHCPDARGS=eth0
Run the following command to ensure that the DHCP service will be started at each boot:
chkconfig --level 345 dhcpd on
6. Configure xinetd and TFTP services. At this point, the TFTP server should be installed.
Enable the TFTP server by using the chkconfig command line utility as follows:
chkconfig tftp on
Ensure that xinetd is enabled, as TFTP is started and stopped by xinetd, using the following command:
chkconfig --level 345 xinetd on
Notify xinetd that the TFTP service has been enabled. Use the following command:
service xinetd restart
7. Add the next-server and filename options into the /etc/dhcpd.conf files. To accomplish this task,
8. Optional step: Assign fixed addresses to each of the clients. The benefit is having the ability to
host 00080246e75d { hardware ethernet 00:08:02:46:e7:5d; fixed-address 172.48.1.253; }
access the clients with the same IP address. The alternative s to use name resolution such as DNS:
In this example, the server was named according to its MAC address. Its MAC address is listed along with the fixed IP address we want associated with it.
9. After modifying /etc/dhcpd.conf, notify the dhcpd server of the changes by using the following
Warning Do not run a new DHCP server on a network with an existing one unless you have configured the network for multiple DHCP servers. Running two or more DHCP servers on the same network without taking special precautions causes conflicts.
Note HP recommends using Syslinux 2.00 or later due to major bug fixes in this version. Red Hat Linux 8.0 includes Syslinux 1.75.
Download and unpack the latest syslinux package from www.kernel.org/pub/linux/utils/boot/syslinux/RPMS. Install the syslinux package using this command:
rpm -hUv syslinux-2.02-1.i386.rpm
Method 1: storing the Linux installation media as ISO images To use RHupdate with this method, place the updates.img file next to the ISO images. To perform an ISO image dump, use the following commands:
Note It is not necessary to mount each CD after insertion. The dd command is not affected by the act of mounting the CD.
mkdir -p /var/ftp/pub/rhl80 cd /var/ftp/pub/rhl80 insert CD #1 dd if=/dev/cdrom of=Psyche-i386-disc1-boxset.iso insert CD #2 dd if=/dev/cdrom of=Psyche-i386-disc2-boxset.iso insert CD #3 dd if=/dev/cdrom of=Psyche-i386-disc3-boxset.iso
Method 2: unpacking the Linux installation media to a directory To use RHupdate with this method, place the updates.img file image in the RedHat/base/ directory. Alternatively, you may place the contents of the updates.img file image into the RedHat/RHupdates/ directory of the unpacked source media. Unpacking the source media will also allow for updated RPMs. Since Red Hat Linux 7.2 and Red Hat Linux Advanced Server 2.1 cannot use ISO images to perform installs, the contents of the CDs must be unpacked to a directory on the server to enable the automated installs described in this document. To unpack the base media to a directory, choose one of the following options: Option 1: dumping from ISO images
mkdir -p /var/ftp/pub/rhl72/i386 cd /var/ftp/pub/rhl72 for X in enigma-i386-disc1.iso enigma-i386-disc2.iso; do mkdir $X.dir; mount $X $X.dir -o loop; (cd $X.dir && tar -cf - .)|(cd i386 && tar -xvf -); umount $X.dir; rmdir $X.dir; done
2. Place the kickstart file on the NFS server along with Red Hat Linux 8.0 ISO images 1, 2, and 3 to
Note A kickstart file is generated after installation or the redhat-configkickstart program may be run. Older versions of Red Hat Linux use ksconfig. The kickstart file provided in Appendix b has been tested and works with Red Hat Linux 7.2, Red Hat Linux 7.3, Red Hat Linux 8.0, and Red Hat Enterprise Linux 2.1. If a required keyword for the specified Linux distribution is missing, the installation will stop and wait for user input at the console.
In this client example, we will perform a Red Hat Linux 8.0 installation. Most files will be placed into the /tftpboot directory and syslinux.cfg will be placed in /tftpboot/pxelinux.cfg. With the Red Hat 8.0 Linux CD-ROM and bootnet.img floppy inserted, perform the following commands:
cp -a /mnt/cdrom/images/bootnet.img /tftpboot/rhl80-bootnet.img cd /mnt/floppy cp -a syslinux.cfg /tftpboot/pxelinux.cfg/rhl80-syslinux.cfg
The initrd.img and vmlinuz can also be copied from the /images/pxeboot directory of Red Hat Linux 8.0 CD #1 rather than from the bootnet floppy. The vmlinuz from /images/pxeboot is an exact copy of the one on the bootnet floppy. The initrd.img file contains more drivers than the bootnet.img file. Ensure that the permissions on /tftpboot allow anonymous access by using this command:
chmod -R o=rx /tftpboot
those in the /tftpboot directory. The following commands used in vi are helpful to make these global changes in the rhl80-syslinux.cfg file:
Once the previous steps are complete, the following directory structure will exist:
Note Run the "import-to-tftpboot.sh" script located in Appendix b to automatically accomplish the tasks described this step.
5. A configuration file must be created to control what happens when the PXE client boots to PXE.
As an example, we will create the rhl80-kickstart-install-syslinux.cfg file by copying it from rhl80syslinux.cfg using the following command:
cp -a rhl80-syslinux.cfg rhl80-kickstart-install-syslinux.cfg
to HEX. In this example, the client server, 172.48.1.253, converted to HEX is AC3001FD. Use these commands to create the soft link:
cd /tftpboot/pxelinux.cfg ln -s rhl80-kickstart-install-syslinux.cfg AC3001FD
Another acceptable soft link to create is one named "default." The use of the default entry affects any clients that may PXE boot and do not have a specific HEX IP address entry in /tftpboot/pxelinux.cfg. In the following example, we demonstrate linking the sample "localbootsyslinux.cfg" to a soft link called "default":
cd /tftpboot/pxelinux.cfg ln -s localboot-syslinux.cfg default
PXE is often the fourth choice in the boot order list. If no bootable media is found in the floppy, CD-ROM drive, or hard drive, it will default to PXE. If the hard drive has been partitioned, it may no longer default to PXE even though the hard drive is not bootable. In some large cluster farms, boot to PXE is moved to the top of the boot order. Then the PXE server, through the use of soft links in the /tftpboot/pxelinux.cfg directory, controls whether the client loads a new operating system or if the client boots to its hard drive.
Alternative methods include: Press F12 during POST to boot to PXE. If the HP Server Management Drivers and Agents (hpasm) are loaded on the server being reprovisioned, set the server to a one-time PXE boot by typing:
/sbin/bootcfg -P
This setting allows for changes in the boot process without updating the BIOS or the need to press F12.
Note For bootcfg usage information, refer to the "Troubleshooting" section.
Troubleshooting
This section contains usage information, potential issues, and additional configuration steps to aid in troubleshooting.
10
Receiving an unauthenticated mount in which the server cannot do a reverse lookup on client IP to compare it to the "permissions" string in /etc/exports is also possible. To correct this issue, either add the client IPs to the /etc/hosts of the NFS server or define them in DNS for proper reverse lookups. Add appropriate lines to the dhcpd.conf file to notify the client about the location where DNS and gateway services reside.
option domain-name option domain-name-servers option routers "testnetwork.com"; 172.48.0.1, 172.48.0.2; 172.48.0.51;
A faster verification alternative is to use the IP subnet information in /etc/exports instead of "*" so that the server will not try the reverse lookup.
3. Display the login prompt on the serial port. Add "s0:12345:respawn:/sbin/agetty 115200 ttyS0 4. Allow root to login on the serial port. Add "ttyS0" to /etc/securetty.
To automate the above process, place the following script in the %post section of the kickstart file:
## ## Configure LILO/GRUB to show Linux Boot Sequence on both the Serial ## Console (ttyS0) and Screen #1 (tty1) ## if [ -f /etc/lilo.conf ]; then DEFAULT=`cat /etc/lilo.conf | grep default` mv /etc/lilo.conf /etc/lilo.conf.sav cat /etc/lilo.conf.sav | awk "{gsub(\"$DEFAULT\",\"$DEFAULT\nappend=\\\"console=ttyS0,115200 console=tty1\\\"\"); print}" >/etc/lilo.conf /sbin/lilo fi if [ -f /boot/grub/grub.conf ]; then mv /boot/grub/grub.conf /boot/grub/grub.conf.sav cat /boot/grub/grub.conf.sav | awk '{if ($1 ~ /kernel/){print $0 " console=ttyS0,115200 console=tty1"} else {print}}' > /boot/grub/grub.conf fi
## ## Do KUDZU serial fix by making serial port "safe" (SAFE=yes) ## mv /etc/sysconfig/kudzu /etc/sysconfig/kudzu.sav cat /etc/sysconfig/kudzu.sav | sed -e 's/^[sS][aA][fF][eE]=.*/SAFE=yes/' /etc/sysconfig/kudzu >
##
11
## Show login prompt on serial port ## mv /etc/inittab /etc/inittab.sav cat /etc/inittab.sav | awk '{gsub("6:2345:respawn:/sbin/mingetty tty6","6:2345:respawn:/sbin/mingetty tty6\ns0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100"); print}' >> /etc/inittab
## ## Allow root to login on the serial port ## cat /etc/securetty | grep "^ttyS0" >/dev/null || echo ttyS0 >> /etc/securetty
12
Appendix a: glossary
In this glossary, terms are listed alphabetically with detailed descriptions for each entry.
Table 3. Glossary terms1 Term Dynamic Host Configuration Protocol (DHCP) Definition DHCP is a protocol used for assigning dynamic IP addresses to a device on a network. DHCP simplifies network administration because the software keeps a log of IP addresses it hands out dynamically. By this action, it allows an administrator to add computers to a network without the hassle of manually assigning a unique IP address each time. A dynamic IP address is an address dynamically assigned by the DHCP server. As the name implies, dynamic addressing most often uses a different IP address each time the computer or network device requests an IP address from the DHCP server. The computer or network device will use this assigned IP address until it is turned off. A fixed IP address takes the best attributes of both the dynamic and static IP address schemes. In this case, the DHCP service supplies the server with an address that never changes. This assignment eliminates the need to manually configure a static IP address on the server and allows that same network device to be moved easily into an environment that participates in DHCP addresses. This flexibility allows a network device with a fixed IP address to participate on a network using a dynamic IP address without additional configuration on the client side. It is important for each computer or network device participating on a single network to have distinct IP addresses. When two computers or network devices have the same IP address then a conflict is created and one or both systems will have network problems. Automatically configuring IP addresses through a single DHCP server aids in preventing IP address conflicts. The MAC address is your network card's unique hardware number. This MAC address usually is not used directly. It is often paired with an IP address which is then used to communicate with that computer or network device. A static IP address is a permanent IP address (an address that does not change). This address is manually configured, for example, it is not distributed by a DHCP server. The network administrator usually controls which static IP addresses are in use and who is able to use them.
Dynamic IP Address
Fixed IP Address
IP Address Conflict
Static IP Address
13
To start the NFS server at the next boot, type the following lines at the command prompt:
chkconfig --level 345 nfs on chkconfig --level 345 nfslock on chkconfig --level 345 portmap on
To start the services now instead of rebooting, type the following lines at the command prompt:
service nfs start service nfslock start service portmap start
syslinux.cfg files Four sample syslinux.cfg files are provided in this section. Sample 1 This script, filename "rhl80-interactive-install-syslinux.cfg," performs an interactive installation, requiring user interaction.
# Install Red Hat 8.0 default linux prompt 1 timeout 600 display rhl80-boot.msg F1 rhl80-boot.msg F2 rhl80-options.msg F3 rhl80-general.msg F4 rhl80-param.msg F5 rhl80-rescue.msg F7 rhl80-snake.msg label linux kernel rhl80-vmlinuz append initrd=rhl80-initrd.img lang= devfs=nomount ramdisk_size=9216 ...
14
Sample 2 This script, filename "rhl80-kickstart-install-syslinux.cfg," performs an automated installation using a kickstart file.
# Install Red Hat 8.0 via kickstart file default ks prompt 1 timeout 20 display rhl80-boot.msg ... label ks kernel rhl80-vmlinuz append ks=nfs:172.48.0.1:/var/ftp/pub/kickstart/rhl80-ks.cfg initrd=rhl80initrd.img lang= devfs=nomount ramdisk_size=9216 ksdevice=eth0 ...
Sample 3 This script, filename "rhl80-bootnet.img-syslinux.cfg," explains how to use a boot image to the server.
# Boot to a disk image (bootnet.img) default rhl80-bootnet.img prompt 1 timeout 600 ... label rhl80-bootnet.img kernel memdisk append initrd=rhl80-bootnet.img ...
Sample 4 This script, filename "localboot-syslinux.cfg," tells the server to boot locally.
# Perform a local boot default localboot prompt 1 timeout 20 ... label localboot localboot 0 ...
15
import-to-tftpboot.sh file The "import-to-tftpboot.sh" script imports a bootnet.img floppy into the /tftpboot directory and automatically renames the files based on the given name.
#!/bin/sh TFTPBOOTDIR=/tftpboot PXELINUXDIR=$TFTPBOOTDIR/pxelinux.cfg TMPDIR=/tmp
if [ -z "$2" ]; then echo This code will unpack a floppy image from location SOURCE into /tftpboot and will rename using the specified name; echo Usage: $0 SOURCE NAME; exit; fi
SOURCE=$1 NAME=$2
# Create pxelinux.cfg directory if it does not exist. if [ ! -d $PXELINUXDIR ]; then mkdir -p $PXELINUXDIR; fi
copyfiles() { # This section copies and renames all files except syslinux.cfg. FILES=`ls | grep -v syslinux.cfg`
# This section copies/renames syslinux.cfg and modifies it to point # correctly to the other copied/renamed files. for X in `ls | grep syslinux.cfg`; do sh <<-EOF > $PXELINUXDIR/$NAME-$X `echo -ne "cat $X | sed" for Y in $FILES; do echo -ne " -e \"s,${Y}$\|${Y}[^=],$NAME-&,g\"" done` EOF done } # This section attempts to locate the specified files for copying purposes. if [ -d $SOURCE ]; then if [ `ls $SOURCE | wc -l` -eq 0 ]; then # If SOURCE dir is empty, then attempt to mount that dir. mount | grep $SOURCE || { mount $SOURCE >/dev/null 2>&1 && { cd $SOURCE copyfiles cd / umount $SOURCE
16
} || { echo Unable to mount that directory, no files found } } else # SOURCE dir is not empty, try to copy those files. cd $SOURCE copyfiles fi else # This is not a directory. FILETYPE=`file $SOURCE` case "$FILETYPE" in # "x86 boot sector, system SYSLINUX, FAT (12 bit)" *boot\ sector,\ system\ SYSLINUX,\ FAT\ *) mkdir $TMPDIR/tmp.dir.$$; mount $SOURCE $TMPDIR/tmp.dir.$$ -o loop; cd $TMPDIR/tmp.dir.$$; copyfiles; cd /; umount $TMPDIR/tmp.dir.$$; rmdir $TMPDIR/tmp.dir.$$; ;; *) echo Sorry, image type not found; ;; esac fi
17
option domain-name-servers 172.48.0.1,10.10.20.242; # PXE-specific configuration directives global section if substring (option vendor-class-identifier, 0, 9) = "PXEClient" { filename "pxelinux.0"; next-server 172.48.0.1; } option time-offset option ntp-servers -21600; # Central Standard Time 172.48.0.1;
# option netbios-name-servers 172.48.1.1; # --- Selects point-to-point node (default is hybrid). # --- Don't change this unless you understand Netbios very well # option netbios-node-type 2; range dynamic-bootp 172.48.0.128 172.48.0.255; default-lease-time 21600; max-lease-time 43200; host 00080246e75d { hardware ethernet 00:08:02:46:e7:5d; fixed-address 172.48.1.253; # PXE-specific configuration directives client specific section next-server 172.48.0.1; filename "pxelinux.0"; } host 00508bea8000 { hardware ethernet 00:50:8b:ea:80:00; fixed-address 172.48.1.254; # etherboot-specific configuration directives next-server 172.48.0.1; filename "etherboot.img"; } }
18
syslinux.cfg script A typical "syslinux.cfg" file for Red Hat Linux 8.0 is similar to the following. This script controls which kernel, initrd, and kickstart files are used to boot the PXE clients.
default ks prompt 1 timeout 20 display rhl80-bootnet.img-boot.msg F1 rhl80-bootnet.img-boot.msg F2 rhl80-bootnet.img-options.msg F3 rhl80-bootnet.img-general.msg F4 rhl80-bootnet.img-param.msg F5 rhl80-bootnet.img-rescue.msg F7 rhl80-bootnet.img-snake.msg label ks kernel rhl80-bootnet.img-vmlinuz append ks=nfs:172.48.0.1:/var/ftp/pub/kickstart/rhl80-ks.cfg initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount ramdisk_size=9216 ksdevice=eth0 # Perform a boot to local media; for example, exit pxe. label localboot localboot 0 # Boot to an image file such as a boot floppy. label rhl80-bootnet.img kernel memdisk append initrd=rhl80-bootnet.img
Kickstart file A typical "kickstart" file generated by Kickstart Configurator is similar to the following. This script controls how a Red Hat Linux installation is performed.
# Merged from Red Hat Linux versions: 7.2, EL 2.1, 7.3, 8.0. # Change the line nfs --server 172.48.0.1 --dir /var/ftp/pub/rh73 # to reflect the correct installation directory # for the OS version being installed. # Also, you may need to update the %packages section. # System language lang en_US # The following are the language modules to install. langsupport --default=en_US langsupport en_US # System keyboard keyboard us # System mouse mouse --emulthree genericps/2 # System timezone
19
timezone --utc America/Chicago # Root password rootpw password # Reboot after installation. reboot # Use text mode install. text # Install Red Hat Linux instead of performing an upgrade. install # Use NFS installation media. nfs --server 172.48.0.1 --dir /var/ftp/pub/rh73 # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record. zerombr yes # Clear all partitions from the disk. clearpart --all --initlabel # Disk partitioning information part /boot --fstype ext3 --size 75 --asprimary part swap --recommended part / --fstype ext3 --size 2700 --grow # Use DHCP networking. This is only effective if ks.cfg is local. # network --bootproto=dhcp --device=eth0 # System authorization information auth --useshadow --enablemd5 # Firewall configuration firewall --disabled # Do not configure the X Window System. skipx # Package install information. This is for a minimal install. %packages --resolvedeps wget openssh openssh-clients openssh-server nfs-utils portmap #@Everything %post
Note To perform a full package install, uncomment the @Everything line in the kickstart file.
20
www.redhat.com/docs/ www.redhat.com/docs/manuals/linux/
www.redhat.com/apps/support/resources/
Call to action
To help us better understand and meet your needs for ISS technology information, please evaluate this paper by completing the short survey at www.zoomerang.com/survey.zgi?B5MB4SNPL8MA0MPTMHNE3TGC. Note: This URL will be active through 30 November 2003. Please send questions and further comments about this paper to: [email protected].
2003 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein. TC030904HT, 09/2003