PXE Boot different OS images

I can now PXE Boot both RHEL 7.8 and RHEL 8.1 OS images for virtual machines. Here is what works.

My PXE setup uses three protocos: DHCP, TFP, and HTTP. All fo these are served on the amse host. IRght now, that host is also the hypervisor for my virtual machines.
First, here is what I have for the DHCP configuration:

# cat /etc/dhcp/dhcpd.conf 
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp-server/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
 
allow bootp;
allow booting;
max-lease-time 1200;
default-lease-time 900;
log-facility local7;
option ip-forwarding false;
option mask-supplier false;
 
subnet 192.168.121.0 netmask 255.255.255.0 {
  option routers 192.168.121.1;
  option domain-name-servers 127.0.0.1;
  range  192.168.121.100 192.168.121.150;
  next-server 192.168.121.1;
  filename "pxelinux/pxelinux.0";
}

The default location for tftp is under /var/lib/lib/tftp. This contains a bunch of c32 files I got from the systlinux package. I doubt I actually need them there, but I’ll leave them until I clean up and recreate the server. The real lgic is in /

ls /var/lib/tftpboot/pxelinux
boot78.msg  boot.msg     pxelinux.0    rhel78
boot81.msg  ldlinux.c32  pxelinux.cfg  rhel81

But lets actually start one level deeper, in

# ls -la /var/lib/tftpboot/pxelinux/pxelinux.cfg/
total 56
drwxr-xr-x. 2 root root   157 Jun 18 16:10 .
drwxr-xr-x. 5 root root   143 Jun 18 16:08 ..
lrwxrwxrwx. 1 root root     7 Jun 15 13:56 01-52-54-00-29-0b-bf -> rhel8.1
lrwxrwxrwx. 1 root root     7 Jun 18 10:40 01-52-54-00-2d-74-f1 -> rhel7.8
lrwxrwxrwx. 1 root root     7 Jun 18 10:37 default -> rhel7.8
-rw-r--r--. 1 root root     0 Jun 18 10:44 pxelinux
-rw-r--r--. 1 root root 42821 Jun 18 10:44 pxelinux.0
-rw-r--r--. 1 root root   308 Jun 18 16:10 rhel7.8
-rw-r--r--. 1 root root   307 Jun 18 16:09 rhel8.1
When the Systlinux process tries to download its configuration, it matches first the MAC address, in various forms, and then uses the default file. I have these files created as symlinks to files that have either rhel7 or rehl8 specific data. I could, at this point, remove the ‘default’ symlink, and both of the virtual machines I’ve defined would continue to provision based on their mac addresses. Here is what the RHEL 7 version looks like:
# cat  /var/lib/tftpboot/pxelinux/pxelinux.cfg/rhel7.8 
timeout 10
display boot78.msg
default 1
prompt  1
 
label 1
  menu label ^Install Red Hat Enterprise Linux 7.8
  kernel rhel78/vmlinuz
  append initrd=rhel78/initrd.img showopts  method=http://192.168.122.1/rhel7.8  ks=http://192.168.122.1/kickstart/rhel7.8.conf ip=dhcp net.ifnames=0 biosdevname=0
 
menu end
-rw-r--r--. 1 root root   307 Jun 18 16:09 rhel8.1

At the top I have pulled in a version specific display file. This is a debugging/logging option to let the user know which thing they are intalling. It looks like this:

# cat  /var/lib/tftpboot/pxelinux/boot78.msg 
Welcome to the installation of "My Linux Server" !
Red Hat Enterprise linux 7.8 (x86_64)
Version: 1.0
Architecture: x86_64
 
Automatically installing  Install Red Hat Enterprise Linux 7.8

I’ve removed all but the essential option that will be used to download the kernel, the initrd, and that describes where to get the system appropriate Kickstart information.

Note that the Kernel and initrd are specific to the version of RHEL I wish to provision. These come out of the ISO files, which are currently mounted loopback. I added these lines to /etc/fstab:

/var/lib/libvirt/images/rhel-8.1-x86_64-dvd.iso /var/www/html/rhel8.1/ iso9660 loop,ro 0 0
 
/var/lib/libvirt/images/rhel-server-7.8-x86_64-dvd.iso /var/www/html/rhel7.8/ iso9660 loop,ro 0 0

You can find the boot files in /var/www/html/rhel7.8/isolinux/ and comparable. By mounting them loopback, I can export the YUM repos pre-created with minimal effort.

In order to get a correct-ish kickstart config, I first installed each OS via the graphical installer. One the install completed, I grabbed it off the Virtual Machine /root/anaconda-ks.cfg and put it in an OS appropriate place in the Web Servers directory. The RHEL 7.8 specific file is in /var/www/html/kickstart/rhel7.8.conf. I had to make a minimum of changes to get it to run unattended, and without graphical mode:

# diff /var/www/html/kickstart/rhel7.8.conf.orig /var/www/html/kickstart/rhel7.8.conf
7c7
< graphical
---
> cmdline
16a17,19
> 
> repo --name="ISO" --baseurl=http://192.168.122.1/rhel7.8/AppStream 
>

This required fewer changes than I made to the RHEL8 one I posted earlier.

I have two VMs defined. One boots RHEL8 and one boots RHEL 7. A few nexts steps:

  • Update to latest RHEL 8.2
  • Convert the current setup to allow me to vary between VM based and Physical Setups. Mostly this is going to involve changes to the kickstart config files. It also is going to require a minimum of duplication, as the menu file selects the kickstart, and they will be very close to similar
  • Boot a RHEL 7.8 Physcial server. This will be a Dell Poweredge i610
  • Figure out how to boot a RHEL 8.1 server with a Driver disk so I can bring up the Poweredge; it has too old of a Disk controller for RHEL 8.

I made heavy use of several other articles to get to this state. Here are a couple of them. The primary one I followed was

https://www.golinuxcloud.com/configure-kickstart-pxe-boot-server-linux/

However, since that uses NFS, and I wanted to use http to serve the packages, I implemented several of the features found in this one,

https://www.golinuxcloud.com/configure-pxe-boot-server-centos-redhat-7-linux

This article helped me realize I was using the RHEL 8 image when trying to provision RHEL7. I had the same error

https://forum.level1techs.com/t/pxe-booting-centos-7-dracut-timeouts-leading-to-dev-root-doesnt-exist/128314

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.