How to configure/setup a PXE server for UEFI boot for Red Hat Enterprise Linux?
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
Issue
- How to configure/setup a PXE server for UEFI boot for Red Hat Enterprise Linux 7/8/9?
Resolution
NOTE: For RHEL 10 PXE configuration refer this article.
For the showcase, we will set up the following configuration:
- Network ID : 192.168.0.0/255.255.255.0
- DHCP Server IP : 192.168.0.254/255.255.255.0
- Subnet Range : 192.168.0.100-192.168.0.200/255.255.255.0
- Gateway : 192.168.0.254/255.255.255.0
- TFTP Server : 192.168.0.254/255.255.255.0
- DNS Server : 192.168.0.254/255.255.255.0
- Installation Repository :
http://192.168.0.254/rhel-7.5
-
Install the required packages
# yum -y install tftp-server dhcp syslinux -
Configure the
dhcpdserviceThe
/etc/dhcp/dhpd.conffile should look like the following:option space pxelinux; option pxelinux.magic code 208 = string; option pxelinux.configfile code 209 = text; option pxelinux.pathprefix code 210 = text; option pxelinux.reboottime code 211 = unsigned integer 32; option architecture-type code 93 = unsigned integer 16; class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; next-server 192.168.0.254; if option architecture-type = 00:07 { filename "shim.efi"; } else { filename "pxelinux/pxelinux.0"; } } subnet 192.168.0.0 netmask 255.255.255.0 { option routers 192.168.0.254; range 192.168.0.1 192.168.0.253; } -
Configure the
tftpserverThe
treestructure of/var/lib/tftpbootshould look like follows:/var/lib/tftpboot/ ├── grub.cfg => see below, the grub2 configuration file ├── grubx64.efi => grub2 boot loader, taken from the grub2-efi-x64 package (is identical to the one in the .iso - EFI/BOOT/grubx64.efi) ├── images │ └── rhel-7.5 │ ├── initrd.img => initial ramdisk from the .iso - images/pxeboot/initrd.img │ └── vmlinuz => kernel for the installation from the .iso - images/pxeboot/vmlinuz ├── pxelinux │ ├── boot.msg => a text message to display when booting legacy (BIOS-like), taken from the .iso from isolinux/ │ ├── initrd.img -> ../images/rhel-7.5/initrd.img => a symbolic link with relative path, my iPXE BIOS insisted on rooting in /pxelinux │ ├── pxelinux.0 => the bootloader for PXE booting in legacy, taken from the syslinux RPM from rhel-7.5 (/usr/share/syslinux) │ ├── pxelinux.cfg │ │ └── default => the configuration of the bootloader (the menu), see below, but not used during UEFI boot, only legacy │ ├── splash.png => a splash image (picture), I don't think it's actually being used, taken from the .iso from isolinux/ │ ├── vesamenu.c32 => the binary that the bootloader chainloads to display the graphical menu, taken from the syslinux RPM (it's also on the .iso in isolinux/) │ └── vmlinuz -> ../images/rhel-7.5/vmlinuz => a symbolic link with relative path, my iPXE BIOS insisted on rooting in /pxelinux └── shim.efi => the bootloader that gets called from the PXE client during UEFI boot, taken from the shim-x64 RPM (is identical to the one in the .iso - EFI/redhat/shim.efi and EFI/BOOT/BOOTX64.EFI) -
Create the Menu files in the same directory with the contents below.
-
/var/lib/tftpboot/pxelinux/pxelinux.cfg/defaultdefault vesamenu.c32 prompt 1 timeout 300 display boot.msg label linux menu label ^Install system menu default kernel vmlinuz append initrd=initrd.img ip=dhcp inst.repo=http://192.168.0.254/rhel-7.5 label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img ip=dhcp inst.xdriver=vesa nomodeset inst.repo=http://192.168.0.254/rhel-7.5 -
/var/lib/tftpboot/grub.cfgset timeout=60 menuentry 'RHEL 7' { linuxefi /images/rhel-7.5/vmlinuz ip=dhcp inst.repo=http://192.168.0.254/rhel-7.5 initrdefi /images/rhel-7.5/initrd.img }
-
-
Enable and start the services
# systemctl enable tftp.socket --now # systemctl enable dhcpd --now
For more details, refer this link
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.