PXE, or Preboot eXecution Environment, allows you to instruct computers to boot using network resources. This allows you to control a single source to install servers without the need to physically insert cumbersome DVDs or USB sticks.
With this recipe, we'll install and configure PXE boots from the RHEL 7 installation media, as follows:
~]# yum install -y dnsmasq syslinux tftp-server
/etc/dnsmasq.conf
, as follows:# interfaces to bind to interface=eno1,lo # the domain for this DNS server domain=rhel7.lan # DHCP lease range dhcp-range= eno1,192.168.0.3,192.168.0.103,255.255.255.0,1h # PXE – the address of the PXE server dhcp-boot=pxelinux.0,pxeserver,192.168.0.1 # Gateway dhcp-option=3,192.168.0.254 # DNS servers for DHCP clients(your internal DNS servers, and one of Google's DNS servers) dhcp-option=6,192.168.1.1, 8.8.8.8 # DNS server to forward DNS queries to server=8.8.4.4 # Broadcast Address dhcp-option=28,192.168.0.255 pxe-prompt="Press F1 for menu.", 60 pxe-service=x86_64PC, "Install RHEL 7 from network", pxelinux enable-tftp tftp-root=/var/lib/tftpboot
dnsmasq
using the following:~]# systemctl enable dnsmasq ~]# systemctl start dnsmasq
xinet
daemon by running the following:~]# systemctl enable xinetd ~]# systemctl start xinetd
tftp
server's xinet
daemon, as follows:~]# sed -i '/disable/ s/yes/no/' /etc/xinetd.d/tftp
syslinux
boot loaders to the tftp
server's boot directory by executing the following command:~]# cp -r /usr/share/syslinux/* /var/lib/tftpboot
~]# mkdir /var/lib/tftpboot/pxelinux.cfg
/var/lib/tftpboot/pxelinux.cfg/default
.default menu.c32 prompt 0 timeout 300 ONTIMEOUT local menu title PXE Boot Menu label 1 menu label ^1 - Install RHEL 7 x64 with Local http Repo kernel rhel7/vmlinuz append initrd=rhel7/initrd.img method=http://repo.critter.be/rhel/7/os/x86_64/ devfs=nomount ks=http://kickstart.critter.be/kickstart.ks label 2 menu label ^2 - Boot from local media
initrd
and kernel
from the RHEL 7 installation media to /var/lib/tftpboot/rhel7/
, and run the following commands:~]# mkdir /var/lib/tftpboot/rhel7 ~]# mount -o loop /dev/cdrom /mnt ~]# cp /mnt/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/rhel7/ ~]# umount /mnt
~]# firewall-cmd --add-service=dns --permanent ~]# firewall-cmd --add-service=dhcp --permanent ~]# firewall-cmd --add-service=tftp --permanent ~]# firewall-cmd --reload
DNSMASQ takes care of pointing booting systems to the tftp
server by providing the enable-tftp
option in the dnsmasq
configuration file.
Syslinux is needed to provide the necessary binaries to boot from the network.
The tftp
server itself provides access to the syslinux
files, RHEL 7 kernel, and initrd
for the system to boot from.
The PXE configuration file provides the necessary configuration to boot a system, including a kickstart file that automatically installs your system.
This recipe's base premise is that you do not have a DHCP server installed. In most companies, you already have DHCP services available.
If you have an ISC-DHCP server in place, this is what you need to add to the subnet definition(s) you want to allow in PXE:
next-server <ip address of TFTP server>; filename "pxelinux.0";
Check out Chapter 8, Yum and Repositories to set up an RHEL 7 repository from the installation media.