In order to setup a PXE installation the following must be carried out:
- Install the necessary packages
- Configure the network (NFS, FTP, HTTP) server to export the installation tree (redhat packages, etc)
- Configure the DHCP server
- Configure the files on the tftp server necessary for PXE booting
- Configure which hosts are allowed to boot from the PXE configuration
- Configure the Kickstart file
- Boot and start the installation
The following software packages are required
- tftp-server-*
- tftp-client-* (for testing)
- dhcp-*
- xinetd-*
- system-config-netboot-* (supplies the prelinux.0 file)
In my examples below i have used the directory /export/kickstart but this could be anything you like.
Basically create the directory and share the directory to the world, then copy the complete fedora/RHEL dvd or cdroms to this directory, once copied you should have something simular to below
total 52 drwxr-xr-x 10 root root 4096 Oct 6 13:38 . drwxr-xr-x 3 root root 4096 Oct 6 09:45 .. drwxrwsr-x 4 root root 4096 Mar 15 2006 Fedora drwxrwsr-x 3 root root 4096 Mar 15 2006 figs drwxrwsr-x 4 root root 4096 Mar 15 2006 images drwxrwsr-x 2 root root 4096 Mar 15 2006 isolinux drwxr-xr-x 2 root root 4096 Oct 6 14:00 ks (this is where my kickstart files are held) drwx------ 2 root root 16384 Oct 6 09:47 lost+found drwxrwsr-x 2 root root 4096 Mar 15 2006 repodata drwxrwsr-x 2 root root 4096 Mar 15 2006 stylesheet-imagesDHCP Installation
Once the DHCP package has been installed, a basic configuration file needs to be setup in /etc/dhcpd.conf, again this configuration file can be has advanced as you want it to be.
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
ddns-update-style ad-hoc;
deny unknown-clients;
not authoritative;
option domain-name "example.com";
option domain-name-servers ???.???.???.???, ???.???.???.???;
option subnet-mask 255.255.255.0;
allow bootp;
allow booting;
option ip-forwarding false; # No IP forwarding
option mask-supplier false; # Don't respond to ICMP Mask req
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
}
group {
next-server 192.168.0.50; # name of your TFTP server
filename "linux-install/pxelinux.0"; # name of the bootloader program
host fedora5 {
hardware ethernet 00:0C:29:D5:B8:A0;
fixed-address 192.168.0.40;
}
}
The above file will setup the host fedora5 (note the specific MAC
address associated to the host fedora5) and boot from the next-server
(tftp server) using the pxelinux.0 boot file, which in turn will look
for the pxe configuration boot file. PXE Boot Configuration Files
The PXE boot configuration basically is setting up the /tftpboot directory to allow clients to download the PXE boot configuration script and allow access to the initial ram disk (initrd.msg) and the linux kernel (vmlinuz).
The tftpboot directory will contain the following directories and files
| /tftpboot/linux-install/prelinux.0 | This file is the PXE boot file and will be run immediately after the the client has connected to the tftp server. |
| /tftpboot/linux-install/msgs | This directory contains the boot messages/menus displayed when the client boots |
| /tftpboot/linux-install/pxelinux.cfg | This directory contains the PXE boot configuration scripts, normally named C0A80023 (ip address of host in HEX) |
| /tftpboot/linux-install/RHEL4 | This directory is optional and is created when using the system-config-netboot or pxeos commands. It is used to hold kickstart scripts, linux kernels and ram disks for specific installations. |
Using the command below will create a directory called RHEL4 and copy the necessary linux kernel and ram disk files (normally located in images/pxeboot directory of the installation tree), we are also stating that we will use NFS to install the OS onto clients
# pxeos -a -i "" -p NFS -D 0 -S
-K nfs::/export/kickstart -L
/export/kickstart RHEL4
| -a | Specifies that an OS instance is being added to the PXE configuration |
| -i | Description of the OS instance |
| -p | Specify which protocol to use for the o/s installation (NFS, FTP, HTTP) |
| -D | Specify if client is diskless (0=network, 1=diskless) |
| -s | Provides the name of the NFS, FTP or HTTP server |
| -L | Provides the location of the installation tree (o/s rpms, etc) |
| -k | provide the specific kernel version of the server installation tree for booting |
| -K | provide the location of the kickstart file |
| os-identifier | OS identifier to keep different build seperate |
default local timeout 100 prompt 1 display msgs/boot.msg F1 msgs/boot.msg F2 msgs/general.msg F3 msgs/expert.msg F4 msgs/param.msg F5 msgs/rescue.msg F7 msgs/snake.msg label 0 localboot 1 label 1 kernel RHEL5/vmlinuz append initrd=RHEL5/initrd.img ramdisk_size=5939 ks=nfs:192.168.0.50:/export/kickstart/ks/default.ksTo setup specific pxe boot configuration files we use a command called pxeboot, this will override the above default boot configuration file
pxeboot -a -K -O OS identifier
| -a | add a specific host |
| -K | location of kickstart file |
| -O | OS identifier |
| hostname | hostname |
default RHEL5
label RHEL5
kernel RHEL5/vmlinuz
append initrd=RHEL5/initrd.img ramdisk_size=5939 ks=nfs:192.168.0.50:/export/kickstart/ks/default.ks
After the client has obtained it's IP address via DHCP it looks for
the following configuration files, as you can see the C0A80028 file is
called which if you remember was created above.Kickstart Configuration file
There are many options to a kickstart configuration file, i have supplied a basic one below which was obtain from a website on the internet, adapt to your own tastes.
install # rather than upgrade
nfs --server=192.168.0.50 --dir=/export/kickstart # Location of the install media, http, nfs etc
lang en_US.UTF-8
langsupport --default en_US.UTF-8
keyboard uk
mouse generic3usb --device input/mice
network --device=eth0 --bootproto=static --ip=192.168.0.40 --netmask=255.255.255.0 --gateway=???.???.???.??? --nameserver=???.???.???.??? -
-hostname fedoraks # we could specify static IP info too instead
rootpw password # noencrypted password
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone Europe/London
bootloader --location=mbr --append="noexec=off hda=noide"
# Any boot time options you wan to add
# I specified noide here as I was booting
# from SAN in this case.
skipx
# do not configure X Windows
zerombr yes
#Clear the Master Boot Record
clearpart --all --initlabel
#Partition clearing information
part /boot --fstype ext3 --size=150 --ondisk=hda
part pv.01 --size=1 --grow --ondisk=hda
part pv.02 --size=1 --grow --ondisk=hda
volgroup rootvg pv.01
volgroup satvg pv.02
logvol / --vgname=rootvg --size=6000 --name=rootvol
logvol swap --vgname=rootvg --size=2000 --name=swapvol
# In the above partition layout (with LVM) I have
# used two disks, sda and sdb for different volumes.
# You don't need to use LVM etc. HDA for IDE etc.
auth --useshadow --enablemd5
#System authorization information
%packages --resolvedeps
# This is the actual package install section. The
# resolvedeps option allows you to make mistakes and
# have anaconda sort it out for you, i.e. resolving
# package dependencies.
@ Base
@ Development Tools
@ Legacy Software Development
# base channels
screen
newt-perl
perl-DateManip
PyXML
ntp
# individual packages to add
-vim
-pico
-emacs
# individual packages to add
%post
# And so begins the post-install section.
# this is currently in a chroot to / on the
# new file system.
# Various variables I like to set first to use later
(
# I run everything in this, so I can log it
/bin/echo "Welcome to $HOSTNAME Server " > /etc/motd
/bin/echo "Built from kickstart version $VER " >> /etc/motd
/bin/echo " " >> /etc/motd
# One way of adding to files
cat >> /etc/sysctl.conf << EOF
fs.aio-max-size = 1048576
fs.file-max = 327680
net.core.rmem_max = 262144
net.core.wmem_max = 262144
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_forward = 0
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
EOF
# Another way of inputing to files
# Here doing some system settings
useradd -c "Some lone user" -d /home/luser luser
echo luserpass | passwd --stdin luser
# Add a user if you like
# Setup hosts file
cat > /etc/hosts << EOF
127.0.0.1 localhost.localdomain localhost
192.168.0.1 install-server.some.domain install-server
192.168.0.2 another.machine.some.domain another
EOF
# Edit the hosts file if you like
wget $SERVER/iptables.$lab -O /etc/sysconfig/iptables
# Here using the server variable we set at the
# top of the post-install section to pull some
# custom files we stored, in this case a firewall.
# In this case using a variable which could have been
# pulled from /proc/cmdline to get a specific one for
# each lab.
/sbin/chkconfig ip6tables off
/sbin/chkconfig isdn off
/sbin/chkconfig sendmail off
/sbin/chkconfig ntpd on
# Turn some services on and off
) > /tmp/kickstart-install.log 2>&1
# The aforementioned log.
Boot and Start the Installation
Just boot the server via the network (normally option F12) and if all
goes well your client should install from the kickstart server, the
basic steps are as follows
Client BIOS (DHCP broadcast)<----------------------------------------> DHCP Server (Network info, tftp server and PXE file name) Client BIOS (TFTP request for pxelinux.0)<---------------------------> TFTP/PXE Server (supplies the pxelinux.0 file) Running PXE (pxe request for kernel and Kickstart install)<----------> TFTP/PXE Server (C0A80028 or default file supplies info) Running Kernel (NFS KICKSTART) <-------------------------------------> NFS Server (supplies the kickstart config file) Running Anaconda (NFS request for rpms)<-----------------------------> NFS Server (supply RPMS) Running Anaconda (NFS request post installtion) <--------------------> NFS Server (runs post install scripts) Running Anaconda (reboot)