Serving up the boot – TFTPD
TFTP is used for simple file transfers over the network. This is most often used to load the initial bootloader for an OS, or some firmware updates for embedded devices and older hardware. In the context of the PXE server, the TFTP system is used for the initial bootloader.
Getting ready
To set up a TFTP server, you will need an Oracle Linux 8 VM running in your environment. The server should be on the same network subnet that the systems being built are using. Ideally, you should also have enough space for several boot files. Normally, 5 GB is enough data space.
How to do it…
Installing TFTP is simple. Run the dnf install -y tftp-server
command, as seen in Figure 2.12.
Figure 2.12 – TFTP installation
Once the installation is complete, we need to open up the firewall for TFTP and reload it:
firewall-cmd --add-service=tftp --permanent firewall-cmd --reload
The output of these commands is as shown in the following screenshot:
Figure 2.13 – TFTP firewall
After installation and the firewall has opened, we need to prepare the system by installing the bootloaders, preparing an Oracle Linux 8 TFTP location, and creating a boot menu.
Note
This example is using a BIOS-based host. If you want to use a UEFI host, you will need to install grub2-efi
and configure UEFI-specific parameters. The Oracle docs for this can be found at https://docs.oracle.com/en/operating-systems/oracle-linux/8/install/install-CreatingaNetworkInstallationSetup.html#uefi-clients.
To install the bootloaders for BIOS-based installs, we will install the syslinux
package. The syslinux
package includes bootloaders for network booting (PXELINUX
), Linux (ext2
/ext3
/ext4
) or btrfs
filesystems (EXTLINUX
), MS-DOS FAT filesystems (SYSLINUX
), and bootable El Torito CD-ROMs (ISOLINUX
). For network booting, we will be using PXELINUX
:
Figure 2.14 – Syslinux installation
Next, we will copy the boot image file, pxelinux.0
, and copy the file into /
var/lib/tftpboot
:
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
Then, we will create an Oracle Linux 8 boot directory under tftpboot
:
mkdir /var/lib/tftpboot/ol8
Now, we need to copy over the PXE boot files from the ISO we previously mounted when installing the HTTP server to the new Oracle Linux 8 boot directory:
cp /var/www/html/OL8/images/pxeboot/* /var/lib/tftpboot/ol8/
Next, we need a boot menu. Luckily, we can copy over the samples and get things moving quickly. We only need the menu files, so using the following command to copy things works just fine:
cp -v /usr/share/syslinux/{ldlinux.c32,libcom32.c32,libutil.c32,menu.c32,vesamenu.c32} /var/lib/tftpboot/
Almost done here. To make a directory for the PXS config files and build the default menu, use the following:
mkdir /var/lib/tftpboot/pxelinux.cfg
We can finally install a config file. Copy this sample configuration file into /var/lib/tftpboot/pxelinux.cfg/default
:
default linux-auto prompt 1 timeout 60 display boot.msg label linux-auto menu label ^Install OL8 in Graphical Mode using the kickstart file menu default kernel ol8/vmlinuz append initrd=ol8/initrd.img ip=dhcp inst.repo=http://pxe.lab.m57.local/ol8 ks=http://pxe.lab.m57.local/ks_files/ol8ks.cfg label linux-manual menu label ^Install OL8 in Graphical Mode with manual input menu default kernel ol8/vmlinuz append initrd=ol8/initrd.img ip=dhcp inst.repo=http://pxe.lab.m57.local/ol8 label rescue menu label ^Rescue installed system kernel ol8/vmlinuz append initrd=ol8/initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff
In this sample, the default install will be linux-auto
, and that will start in 60 seconds unless the user manually selects one of the following options:
linux-auto
: This is the default and will install Oracle Linux using the kickstart parameterslinux-manual
: This will kick off a traditional install or Oracle Linux, prompting the user to select all the options from Anaconda manuallyrescue
: This will boot in rescue modelocal
: This will boot from the existing local disk
You can easily modify the menus as needed to meet your specific needs. PXE booting, while daunting at first, provides a powerful tool to manage your Linux installations.
How it works…
When systems boot, they will load the bootloader based on the DHCP server config. This will then have the system boot from the TFTP server, starting the PXE process.