PXE Boot — Installing RedHat OS like a Pro.

Iqbal Singh
5 min readSep 6, 2020

--

Covid-19 has changed a lot of things in the world and working remotely is one of the major changes that happened to the IT industry. Offices were closed, for getting anything done in the office or to fix some machines you have to work with IT, which can take weeks some time.

While WFH , I picked up a project to set up an R&D K8s Cluster and the biggest challenge was to install the operating system on these machines remotely. I have worked a lot on setting up Hadoop, Mesos clusters in past but never worked on PXE booting the machines remotely for those projects.

Always loved working on new technologies and started working on this project, learned along the way and set up the OS in 2 weeks' time. I am sharing the details on how to set up OS on a set of machines remotely.

Tools

One requires knowledge of the below tools/commands for setting up a machine, there are other options available as well for each one of them.

PXE boot

Preboot eXecution Environment (PXE, most often pronounced as pixie) 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.

A high-level overview of the system calls for a network boot.

PXE boot

kickstart

Many system administrators set up multiple systems at a time and would prefer to use an automated installation method to install Red Hat Enterprise Linux on their machines. To answer this need, Red Hat created the kickstart installation method. Using kickstart, a system administrator can create a single file containing the answers to all the questions that would normally be asked during a typical installation.

  • We can describe the disc formatting we need in the kick start file to avoid the tedious disc configuration set up during installation.
  • We can easily enable and configure the IP tables on the machines using a kickstart file for ssh and other port access on the machine.

Cobbler

Cobbler is a Linux installation server that allows for rapid setup of network installation environments. It glues together and automates many associated Linux tasks so you do not have to hop between many various commands and applications when deploying new systems, and, in some cases, changing existing ones. Cobbler can help with provisioning, managing DNS and DHCP, package updates, power management, configuration management orchestration, and much more.

Once the cobbler server is installed, you can download and mount the required OS iso file on your machine and can start the below commands.

There are three main concepts for installing the operating system using the Cobbler server. Distro, Profile and System

Distro
Distro command Add the operating system we want to install to the cobbler system. Any RedHat OS distribution can be imported into the cobbler system using the below commands.

Profile
Once the operating system distribution is set up, A OS profile needs to be set up for the installation process. A profile will attach a kickstart installation file to a distribution.

System
The last step is to add the client machine network IP and MAC address to the cobbler system so that during the next boot machine will send out a DHCP request for boot files over the network and the Cobbler system can authenticate the machine based on the details.

Foreman is another tool that can be used instead of Cobbler and it is getting a lot of traction these days, it also comes with a nice and easy to access UI.

https://theforeman.org/

Ipmitool

I was planning to install the operating system on very old machines and those machines had no tool as iDrac for accessing the kernel level properties remotely. I used Intelligent Platform Management Tool ipmitool for accessing the boot configurations on the machines and update the boot order to use network boot on the next restart(one time only).

https://github.com/ipmitool

Setting up the OS

  • Read the instructions and install the Cobbler server on a machine with the same network as the client machines.
  • Make sure you have network access on the root user for the Client OS machines.
  • Get the IP, Hostname and Mac Address for the client machine where the OS has to be installed.
  • for MAC address, if you use etho NIC (cat /sys/class/net/eth0/address)
  • Install and set up ipmitool on the client machine for enabling the network boot option remotely.

Disclaimer: Wiping a machine and installing a new Operating system will remove all the data from the machine and will also format the drives based on the kickstart file configuration. Please test the process on a test server before rolling out in production also make sure to check the documentation for the tools you are using.

Steps

  1. Download and mount the required operating system distribution on the cobbler server. (for CenOS 8)
wget http://mirror.csclub.uwaterloo.ca/centos/8.1.1911/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso# mkdir /mnt/iso/c8-1
# mount -t iso9660 -o loop /root/isingh/iso/CentOS-8.1.1911-x86_64-dvd1.iso /mnt/iso/c8-1

# mount | grep iso
/root/isingh/iso/CentOS-8.1.1911-x86_64-dvd1.iso on /mnt/iso/c8-1 type iso9660 (rw,loop=/dev/loop1)

2. Import the Os into the cobbler system, add the distribution and check the report for the distribution details.

cobbler import --path=/mnt/iso/c8-1 --name=CentOS-8.1.1911-x86_64cobbler distro add \
--name=CentOS-8.1.1911-x86_64 \
--kernel=/var/www/cobbler/ks_mirror/CentOS-8.1.1911-x86_64/images/pxeboot/vmlinuz \
--initrd=/var/www/cobbler/ks_mirror/CentOS-8.1.1911-x86_64/images/pxeboot/initrd.img \
-—kopts="ksdevice= inst.repo=http://@@http_server@@/cblr/links/CentOS-8.1.1911-x86_64"
cobbler distro report --name=CentOS-8.1.1911-x86_64

3. Add the cobbler profile for attaching a Kickstarter file to the OS distribution. Use the distro name created in the previous step.

cobbler profile add \ 
--name=TEST-OS-ROLLOUT
--distro=CentOS-8.1-DVD-x86_64 --kickstart=/var/lib/cobbler/kickstarts/reporting-k8s-c8.ks

4. Set up the client system details in the Cobbler server and attach a profile to the system for DHCP call responses and run Cobbler sync to sync all the new configurations in the server.

cobbler system add \ 
--name=newmachine.a2z.com \
--hostname=newmachine.a2z.com \ <= Client Hostname
--profile=TEST-OS-ROLLOUT \
--interface=eth0 \
--ip-address=192.192.192.192 \ <= Client IP
--mac=10:2Z:1X:99:AA:CC \ <= Client Mac Address
--static=1 \
--netmask=255.252.0.0 \
--gateway=192.192.298.250 \
cobbler sync

5. Log in to the Client machine, enable the pxe boot. Use ipmitool or any other inbuilt tool as iDRAC. For ipmitool

## Run below command to enable pxe boot. 
$ ipmitool chassis bootdev pxe
Set Boot Device to pxe
## ERROR: Could not open device at /dev/ipmi0 or /dev/ipmi/0 or /dev/ipmidev/0: No such file or directory
Unable to get Chassis Power Status
## If you get above error enable the kernel modules by running below commands and try again.
modprobe ipmi_devintf
modprobe ipmi_si

6. Reboot the client machine and you will see below while the client machine reboots.

shutdown -r now

OS installation can take 10–30 mins based on the configurations in the kick start file.

Feel free to review and let me know if you find any issues. Thanks for reading.

--

--