22 C
Texas
Muhammad Nabeel
Network and System Administrator

Install PXE Boot server for automated install RHEL 8 and CentOS 8

In computing, the Preboot eXecution Environment (PXE, sometimes pronounced as pixie[1]) specification describes a standardized client-server environment that boots a software assembly, retrieved from a network, on PXE-enabled clients. On the client side it requires only a PXE-capable network interface controller (NIC), and uses a small set of industry-standard network protocols such as DHCP and TFTP.

Today, you will learn how to install and configure PXE Server on RHEL/CentOS 8 with local installation repositories using DNSMASQ Server.

Step 1: Install and configure DNSMASQ Server

use the following command to install DNSMASQ daemon

dnf install dnsmasq -y
- Advertisement -

Now edit /etc/dnsmasq.conf file.
We will backup the old file and create new one and make configuration in it for safety.

mv /etc/dnsmasq.conf /etc/dnsmasq.conf.backup

vi /etc/dnsmasq.conf

Replace below settings according to system and network in dnsmasq.conf file.

interface=ifcfg-ens32,lo
#bind-interfaces
domain=localhost.localdomain.local
# DHCP range-leases
dhcp-range= ens33,192.168.130.4,192.168.130.253,255.255.255.0,1h
# PXE
dhcp-boot=pxelinux.0,pxeserver,192.168.130.138
# Gateway
dhcp-option=3,192.168.130.2
# DNS
dhcp-option=6,92.168.130.2, 8.8.8.8
server=8.8.4.4
# Broadcast Address
dhcp-option=28,192.168.130.255
# NTP Server
dhcp-option=42,0.0.0.0

pxe-prompt="Press F8 for menu.", 30
pxe-service=x86PC, "Install RHEL 8 from PXE server 192.168.130.152", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot

dnsmasq config

Step 2: Install SYSLINUX Bootloaders

Now install Syslinx PXE bootloader package by using following command.

dnf install syslinux -y

Step 3: Install and configure TFTP Server with SYSLINUX Bootloaders

First install TFTP-Server then copy all Syslinux bootloder files from /usr/share/syslinux to /var/lib/tftpboot path, by issuing the following commands.

dnf install tftp-server -y
cp -r /usr/share/syslinux/* /var/lib/tftpboot

Step 4: Configuration PXE Server File

Create directory pxelinux.cfg and configure it with a default file using following commands.

mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default

Now edit PXE configuration file with RHEL installation option. Note that all paths used in this file must be placed in /var/lib/tftpboot directory.

Below you can see an example configuration file that you can use it, but modify the installation images (kernel and initrd files), protocols (FTP, HTTP, HTTPS, NFS) and IPs to reflect your network installation source repositories and paths accordingly.

vi /var/lib/tftpboot/pxelinux.cfg/default

make below changes in this file and replace below IP with your PXE SERVER IP

default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

label 1
menu label ^1) Install RHEL 8 with Local Repo
kernel rhel8/vmlinuz
append initrd=rhel8/initrd.img method=ftp://192.168.130.152/pub devfs=nomount

label 2
menu label ^2) Boot from local drive

Step 5: Add RHEL 8 Boot Images to PXE Server

In this step CentOS kernel and initrd files are required. I will copy these files from rhel 8 bootable USB. You can copy these files from RHEL 8 DVD, Just put RHEL DVD in your DVD drive and mount the image to /mnt path by issuing the below command.

mount -o loop /dev/cdrom /mnt
ls /mnt

Now create RHEL 8 folder and copy RHEL bootable kernel and initrd images from the DVD mounted location to rhel8 folder.

mkdir /var/lib/tftpboot/rhel8
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/rhel8
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/rhel8

Step 6: Create RHEL 8 Local Installation Source

To make local installation source, Install vsftpd packgae, copy all content from DVD to vsftpd path /var/ftp/pub and set permissions to pub folder by using following commands.

Note: copy of the DVD image will take some time.

dnf install vsftpd -y
cp -rv /mnt/* /var/ftp/pub/ 
chmod -R 755 /var/ftp/pub

Step 7: Start and Enable installed services

systemctl start dnsmasq
systemctl start vsftpd
systemctl enable dnsmasq
systemctl enable vsftpd

Step 8: Allow Necessary Services and Ports in Firewalld

firewall-cmd --permanent --add-service={ftp,dns,dhcp} 
firewall-cmd --permanent --add-port={69/udp,4011/udp}
firewall-cmd --reload

Step 9: Boot Clients from Network

Clients PC’s must be on same network to boot from network, so make sure of it

In order to choose network booting. After first PXE prompt appears, press F8 key to enter and then hit Enter key to proceed forward to PXE menu.

After that screen will be appeared to install your RHEL/CENTOS 8

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

8 COMMENTS

  1. Hello,

    Work fine at home, except for one point : it’s the RHEL 7 installer that is started not the RHEL8 one.

    If I boot from the very same ISO,
    where I take the vmlinuz and initrd.img
    and where the ftp is connected
    then the RHEL8 installer ‘ll start.

    Any idea ?

  2. This does not work for me on CentOS 8 , I get an error message that initrd.img is not being found even though it is in the same directory as vmlinuz. I suspect this is a problem with the CentOS 8 vmlinuz version. It would be nice to try this setup also on CentOS 8,

  3. Thanks a lot for the great tutorial. Works perfectly fine!
    There is just one little missing step to allow anonymous FTP users:

    vi /etc/vsftpd/vsftpd.conf
    Change this line:
    anonymous_enable=YES

    Thanks again

  4. Hola a todos, tengo un problema, mi cliente ya reconoce el servidor PXE, llego hasta la pantalla para empezar a instalar el SO RHEL 8 desde el servidor pero no inicia la instalación, espera los 30 segundos en el menú pero no inicial la instalación, que puede estar pasando?

    Muchas gracias por este Post muy bueno.

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article