RHEL-based PXE Kickstart Network Server Setup

Mindwatering Incorporated

Author: Tripp W Black

Created: 10/08 at 04:10 PM

 

Category:
Linux
Installation

Task:
Creation of a PXE Kickstart network-based auto-installation.

Note:
RH has their Satellite Server as a Provision Server offering which they market for this, as well.


WARNING:
Leaving a PXE Kickstart VM running all the time will reinstall a configured workstation or server back to a newly deployed one if the boot order of the workstation or server has the PXE network before Harddisk in the BIOS boot order. This will be really, really bad if you also have automation rebooting a bunch of workstations or servers overnight for security batching.

We recommend not running this VM 24/7 and only when deploying new machines outside of a normal maintenance window.


Prerequisites:
- Requires a network installation server (Kickstart server) with PXE (Pre-boot eXecution Environment), TFTP, and a shared Kickstart file to start an installation by booting onto the network
- Requires host motherboard to be set-up/allow PXE boot
- Requires host NIC that supports PXE boot
- The Kickstart PXE server must have:
- - DHCP server to handle the initial communication, the network configuration (DHCP, and the TFTP server location for the usable boot image
- - TFTP server to provide boot images with command line options to start the installer
- - HTTTP, FTP, and/or NFS server to provide the installation media and the Kickstart file for installation
- UEFI-based boot firmware require additional extra files from the "shim" and "grub2-efi" packages, and a different configuration file
- - Instructions are in the RHEL 8 Installation Guide: Configuring a TFTP Server for UEFI-based AMD64 and Intel 64 Clients
- Unintended network installs use an img file (e.g. squashfs.img) that contains the partitioning config and the disk image config (e.g. LVM) using Thin/Thick Provisioning specifications, and all the packages that will be installed.


PXE Process:
- At boot, the new workstation or server network interface card broadcasts a DHCPDISCOVER packet extended with PXE-specific options.
- The PXE DHCP server on the network replies with a DHCPOFFER, giving the client information about the PXE server and offering an IP address.
- The new workstation/server responds with a DHCPREQUEST
- The PXE server sends a DHCPACK with the Trivial FTP (TFTP) server URL of a file that can boot the client into an installer program.
- The new workstation/server downloads the file from the TFTP server, verifies the file using a checksum, and loads the network boot-loader file received (typically called pxelinux.0).
- The new workstation/server running boot loader accesses a specified configuration file from the boot-loader file on the TFTP server that tells it how to download and start the image installer, and how to locate the Kickstart file on an HTTP, FTP, or NFS server. After verification, the files are used to boot the client.


Steps to Create a RHEL Kickstart VM:
Notes:
- Should not be installed on any virtualization hosts/clusters that might be rebooted and need this VM
- This server will also be the DHCP server as it is currently configured. If you have another DHCP server on the network, you configure that DHCP server to point to this server's TFPBoot and alter the config/roles of this server. These instructions are assuming this PXE Kickstart server will run DHCP, too. If you network has a specific VLAN where new workstations or servers are first imaged, this scenario will work well.
- In this example, we are updating the tftpboot for RHV-H physical servers.
- Example kickstart server FQDN: rhks.mindwatering.net
- Ensure DNS forward A and reverse PTR entries exist for the FQDN. e.g. rhks.mindwatering.net / 10.0.15.1
- The HTTP server to get the images/files does not need to be the PXE Kickstart VM. We have our files on a different server where the files can be accessed anonymously on an HTTP host: rhksfiles.mindwatering.net
- The kickoff file typically includes a starting root password used in your organization that is changed after install/first boot.

1. Install manually a RHEL 8 or RHEL 9 Linux Server with minimal packages.

2. After installation is complete, install the following packages:
$ sudo su -
# yum install syslinux tftp-server dhcp
<confirm and wait>

3. Configure the PXE Kickstart server:
a. Configure the PXE server with the network VLAN "where" new machines will be deployed
# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
10.0.15.1 rhks.mindwatering.net rhks
<esc>:wq (to save)
# nmcli con modify 'eth0' 10.0.x.1 10.0.15.1/24
<confirm network change to current network - 10.0.15.0/24>
# nmcli con down 'eth0' && nmcli con up 'eth0'

b. Create the tftpboot pxelinux folder and copy the prelinux.0 file:
# mkdir /var/lib/tftpboot/pxelinux
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux/

c. Create/update the default config file in pxelinux.cfg folder for the type of machines we are imaging.
Notes:
- Update the label (e.g. rhvh-host), the menu label line (e.g. Install RHV-H host), and the append intrd line with all the paths.
- This is example is for RHV-H servers
# mkdir /var/lib/tftpboot/pxelinux/pxelinux.cfg/
# vi /var/lib/tftpboot/pxelinux/pxelinux.cfg/default
default vesamenuc32
prompt 1
timeout 60

display boot.msg

label rhvh-host
menu label ^Install RHV-H host
menu default
kernel vmlinuz
append initrd=initrd.img ip=dhcp inst.stage2=http://ksfiles.mindwatering.net/rhvhmedia inst.ks=http://ksfiles.mindwatering.net/rhvhks/kickstart.cfg

<esc>:wq (to save)

d. Create the DHCP configuration file:
# vi /etc/dhcp/dhcpd.conf
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;

subnet 10.0.15.0 netmask 255.255.255.0 {
option routers 10.0.15.1;
option subnet-mask 255.255.255.0;
option domain-search "mindwatering.net";
option domain-name-servers 10.0.15.1;

range 10.0.15.11 10.0.15.250;

class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
next-server 10.0.15.1;

if option architecture-type = 00:07 {
filename "uefi/shim.efi";
} else {
filename "pxelinux/pxelinux.0";
}
}
}
<esc>:wq (to save)

e. Update firewalld and open TFTP and DHCP if not already open
Note: Our zone active is public.
# firewall-cmd --zone=public --add-service=dhcp --permanent
# firewall-cmd --zone=public --add-service=tftp --permanent
# firewall-cmd reload
# firewall-cmd state
<view and confirm dhcp and tftp are added>

f. Enable dhcpd and tftp services and start
# systemctl enable dhcpd
# systemctl enable tftpd
# systemctl start dhcpd
# systemctl start tftpd

4. On a workstation, extract/make the image and kickstart files and place them on the HTTP server:
Notes:
- We have a web server with a site named ksfiles.
- The ISO/image file to place are typically within a folder on the installation ISO or in the RPM file of the software to automatically install
- - In this case, for RHV-H, the file is w/in the .rpm file within the ISO image, RHVH-4.x-yyyymmdd.x-RHVH-x86_64-dvd1.iso.
a. Mount and extract the rpm:
$ cd ~/Downloads/
$ mount RHVH-4.x-yyyymmdd.x-RHVH-x86_64-dvd1.iso /mnt
$ ls -la /mnt/Packages
<view output - e.g. redhat-virtualization-host-image-update-4.x-yymmdd.0.el7_6.noarch.rpm>
$ rpm2cpio /mnt/Packages/redhat-virtualization-host-image-update-4.x-yymmdd.0.el7_6.noarch.rpm | cpio -idmv
<wait for extraction of the redhat-virtualization-host-4.x-yyyymmdd.0.el7_6.squashfs.img into current directory>

b. Rename the squashfs.img file to just squashfs.img so life is simpler:
$ mv redhat-virtualization-host-4.x-yyyymmdd.0.el7_6.squashfs.img squashfs.img

c. Upload/copy squashfs.img via FileZilla or scp to HTTP server.
Note: Destination for the image is the /var/html/ksfiles/rhvhmedia/ folder specified in step 3c above, where ksfiles is our site, and rhvhmedia is the target folder for the squashfs.img

d. Create the kickoff file to also upload to the HTTP server:
Notes:
- Update the liveimg path to your HTTP server's path and update the rootpw to your corporate standard.
$ vi kickstart.cfg
liveimg --url=http://ksfiles.mindwatering.net/rhvhmedia/squashfs.img
clearpart --all
autopart --type=thinp
zerombr
rootpw --plaintext root_password_in_clear_text
timezone Etc/UTC --isUtc
text
reboot
%post --erroronfail
nodectl init
%end
<esc>:wq (to save)

e. Upload kickstart.cfg to the HTTP server
Note: Destination of the kickstart-file.cfg is the/var/html/ksfiles/rhvhks/ folder on the web server.

5. The kickstart config is ready to be used.
This automation will fire for ANY workstation/server that reboots and starts w/the network PXE-boots.
- The behavior is set by the /var/lib/tftpboot/pxelinux/pxelinux.cfg file. When using UEFI-based systems, the configuration will be slightly different than this example.
- The boot loader specified in the Kickstart file downloads and starts the vmlinuz kernel from the RHV-H installation ISO file. That kernel is invoked with four command-line kernel parameters:
- - initrd=initrd.img to download the initial RAM disk image (initrd.img) that was collocated with the vmlinuz file on the RHV-H ISO.
- - ip=dhcp to obtain a DHCP IP address
- - inst.stage2 directive pointing to a shared URL containing the squash.img file for installation
- - inst.ks directive pointing to the kickstart.cfg file.




previous page

×