How to configure PXE (Network Boot) installation Server on Red Hat Enterprise Linux 7
Updated: Oct 3, 2021
The PXE (Preboot eXecution Environment) Server allows unattended or automated OS (Operating system) installation over the Network. The main benefit of PXE is that we don’t need any bootable drive to boot OS e.g CD/DVD ROM or USB
As a prerequisite, we need to have below network service ready in our system:
DHCP Server: To get a dynamic IP Address in the client system. See "How to Install a DHCP Server in Red Hat Enterprise Linux 7"
TFTP Server: To transfer network boot program files to client systems during network boot up. See "How To Install TFTP Server In Red Hat Enterprise Linux 7"
DNS Server: To provide and configure DNS information in the client system.
HTTP And/or FTP Server: The client will download all the required packages for the OS installation. See "How to configure HTTP Server In Red Hat Enterprise Linux 7" and "How to configure FTP Server In Red Hat Enterprise Linux 7"
Please make sure the IP Address is correct in the configuration file of all the services. If you going to install and configure all service in a single system.
Step1: To verify the DHCP service configuration file and that should have the necessary configuration.
# cat /etc/dhcp/dhcpd.conf
::::::::::::: CUT SOME OUTPUT :::::::::::::
# this is PXE specific
filename "pxelinux.0";
next-server 192.168.122.254;
::::::::::::: CUT SOME OUTPUT :::::::::::::
Step:2 To mount RHEL 7.X ISO file and copy the contents to local ftp server
# mount -o loop RHEL-7.7-x86_64-DVD-15165.iso /mnt/
mount: /dev/loop0 is write-protected, mounting read-only
# cd /mnt/
# mkdir /var/ftp/pub/rhel7
# cp -av * /var/ftp/pub/rhel7/
Step:3 To configure the tftp service for the PXE boot.
# yum install syslinux -y
# cp -rfv /usr/share/syslinux/* /var/lib/tftpboot/
# mkdir /var/lib/tftpboot/pxelinux.cfg
# mkdir /var/lib/tftpboot/rhcos/
Step:4 To copy Kernel file (vmlimz) and initrd file from mounted iso file to local tftp server
# cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/rhcos/
# cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/rhcos/
Step:5 To Install and configure Apache Web Server.
# yum install -y httpd
# ln -s /var/ftp/pub/rhel7 /var/www/html/
# systemctl restart httpd
# systemctl enable httpd
Note: we can create an apache configuration file instead of the symbolic link
Step:6 To create a configuration directory for the PXE server.
# vi /var/lib/tftpboot/pxelinux.cfg/default
# # #
# Some helpfull red hat doc links
# nomodeset
# https://access.redhat.com/solutions/4713651 inst.ks.sendmac
# https://bugzilla.redhat.com/show_bug.cgi?id=1758091
#
default menu.c32
prompt 0
timeout 900
ONTIMEOUT
# ONTIMEOUT local
#
menu title ######## PXE Boot Menu ########
label 1
menu label ^1) Install RHEL 7
kernel rhcos/vmlinuz
append initrd=rhcos/initrd.img method=http://192.168.122.254/rhel7 devfs=nomount
label 2
menu label ^2) Boot from local drive localboot
# # #
Step:7 To make sure all the required service is sunning and enabled.
# systemctl status httpd dhcpd tftp vsftpd
# systemctl status httpd dhcpd tftp vsftpd
# systemctl is-enabled httpd dhcpd tftp vsftpd
# systemctl is-active httpd dhcpd tftp vsftpd
active
active
active
active
Step:8 If Firewalld service is running, we need to open the ports in the OS firewall using following firewall-cmd commands.
# firewall-cmd --add-service=http --permanent
# firewall-cmd --add-service=ftp --permanent
# firewall-cmd --add-service=dhcp --permanent
# firewall-cmd --add-port=69/tcp --permanent
# firewall-cmd --add-port=69/udp --permanent
# firewall-cmd --add-port=4011/udp --permanent
# firewall-cmd --reload
Step:9 To verify and boot the client systems with the PXE boot option.
Below successful PXE Boot will be shown on screen, Once we boot-up the client system via network interface. And after that we can proceed for the installation.
Troubleshooting:
1. If SELinux is enabled with enforcing mode, then set the following SELinux rule for the FTP server.
# setsebool -P allow_ftpd_full_access 1
2. we can create an apache configuration file for PXE server under /etc/httpd/conf.d/ directory instead of link at Steps 4:
# vi /etc/httpd/conf.d/pxeboot.conf
# Add the following lines:
Alias /rhel7 /var/ftp/pub/rhel7/
<Directory /var/lib/tftpboot/rhel7>
Options Indexes FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.122.0/24
</Directory>
Hope this document will help.
Comments