Configuring PXE server for UEFI boot for RHEL6/RHEL7

Red Hat allows you to install the OS over the network using NFS, FTP or HTTP. If the hardware supports PXE (Pre-eXecution Environment) the NIC card will send out a broadcast request for DHCP information. The DHCP server provides the client with a IP address and other network infomation such as the TFTP server address (which provides the files necessary to start the installation) and the location of the files on the TFTP server. This is possible because of PXELINUX, which is part of the syslinux package.

this post is about configuration of PXE server for UEFI boot

Configuration of PXE server

Our Setup for this Configuration:

Target Network is                                           : 192.168.0.0/255.255.255.0

Required DHCP range is                                  : 192.168.0.100  to 192.168.0.200

GATEWAY/TFTPSERVER/DNS SERVER Address   : 192.169.0.254

OS Versions                                                                 : RHEL 6 and RHEL7

 

Step 1: Install the following packages using yum, in case there is no existing DHCP server. If DHCP server is present, modify the existing!

[root@gurkulrhel ~]# yum install tftp tftp-server dhcp -y
Configure the DHCP server. Take following example.

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
Step 2  : The /etc/dhcp/dhpd.conf file should look like the following.
[root@gurkulrhel ~]# cat /etc/dhcp/dhpd.conf
allow booting;
allow bootp;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.254;
range 192.168.0.100 192.168.0.200;
class “pxeclients” {
match if substring (option vendor-class-identifier, 0, 9) = “PXEClient”;
next-server 192.168.0.254;
if option arch = 00:07 {
filename “pxelinux/bootx64.efi”;
}
else {
filename “pxelinux/pxelinux.0”;
}

}
}

Step 3 : Configure the tftp server. Modify the file /etc/xinetd.d/tftp and replace disabled = yes to disabled = no and then restart the xinetd service.

[root@gurkulrhel ~]# vi /etc/xinetd.d/tftp
[root@gurkulrhel ~]# service xinetd restart; chkconfig xinetd on

Step 4: Copy the contents in /var/lib/tftpboot directory for PXE boot.

[root@gurkulrhel ~]# mkdir -p /mnt/{6,7}
[root@gurkulrhel ~]# mount -o loop /path/to/rhel-server-6.6-x86_64-dvd.iso /mnt/6
[root@gurkulrhel ~]# mount -o loop /path/to/rhel-server-7.1-x86_64-dvd.iso /mnt/7
[root@gurkulrhel ~]# mkdir -p /var/lib/tftpboot/pxelinux/{6.6,7.1}
[root@gurkulrhel ~]# cp /mnt/6/isolinux/vmlinuz /var/lib/tftpboot/pxelinux/6.6
[root@gurkulrhel ~]# cp /mnt/6/isolinux/initrd.img /var/lib/tftpboot/pxelinux/6.6
[root@gurkulrhel ~]# cp /mnt/6/EFI/BOOT/BOOTX64.efi /var/lib/tftpboot/pxelinux
[root@gurkulrhel ~]# cp /mnt/7/isolinux/vmlinuz /var/lib/tftpboot/pxelinux/7.1
[root@gurkulrhel ~]# cp /mnt/7/isolinux/initrd.img /var/lib/tftpboot/pxelinux/7.1
[root@gurkulrhel ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux

Step 5: Create a directory pxelinux.cfg in /var/lib/tftpboot

[root@gurkulrhel ~]# mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg
Step 6: Create the Menu files in the same directory with the contents below.

[root@gurkulrhel ~]# cat /var/lib/tftpboot/pxelinux/pxelinux.cfg/default
default rhel6
timeout 10
label rhel6
kernel /6.6/vmlinuz
append initrd=/6.6/initrd.img ramdisk_size=65536 vga=no ip=dhcp ksdevice=bootif ks=http://path/to/ks.cfg
label rhel7
kernel /7.1/vmlinuz
append initrd=/7.1/initrd.img ramdisk_size=65536 vga=no ip=dhcp ksdevice=bootif inst.ks=http://path/to/ks.cfg

[root@gurkulrhel ~]# cat /var/lib/tftpboot/pxelinux/pxelinux.cfg/efidefault
default rhel6
timeout 10
title rhel6
root (nd)
kernel /6.6/vmlinuz
initrd=/6.6/initrd.img ramdisk_size=65536 vga=no ip=dhcp ksdevice=bootif ks=http://path/to/ks.cfg
title rhel7
root (nd)
kernel /7.1/vmlinuz
initrd=/7.1/initrd.img ramdisk_size=65536 vga=no ip=dhcp ksdevice=bootif inst.ks=http://path/to/ks.cfg

Directory tree for tftpboot should appear as below:

tree-structure

 

 

 

 

 

 

Step 7: As a workaround for the EFI PXE, copy the file /var/lib/tftpboot/pxelinux/pxelinux.cfg/efidefault into /var/lib/tftpboot/pxelinux/ directory too. And change the permissions of TFTP contents in case required.

[root@gurkulrhel ~]# cp /var/lib/tftpboot/pxelinux/pxelinux.cfg/efidefault /var/lib/tftpboot/pxelinux/
[root@gurkulrhel ~]# chmod -R 777 /var/lib/tftpboot/

Step 8: Restart the Services and chkconfig them on.

[root@gurkulrhel ~]# service xinetd restart ; chkconfig xinetd on
[root@gurkulrhel ~]# service dhcpd restart ; chkconfig dhcpd on
Finally,

for the Kickstart configuration file, please make sure there is a partition that need to be mounted as /boot/efi with fstype “efi”, for example:

part /boot –fstype=”ext4″ –size=256
part /boot/efi –fstype=”efi” –size=256
part swap –fstype=”swap” –size=1024
part pv.01 –size=10240
volgroup vg0 pv.01
logvol /home –vgname=vg0 –size=500 –name=home
logvol / –vgname=vg0 –grow –size=1 –name=root

Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

1 Response

  1. Nagaraju says:

    very much explanatory

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us