Configuring PXE Boot Loading

The steps to configure a PXE boot loader depends on the type of system that is used for the boot server.

Important:

You must use the correct kernel and ram-disk image for the installation that you intend to support. For example, if you intend to install a system with a Btrfs root partition, you must use the UEK boot ISO to obtain the correct kernel and image for the system to be able to install with Btrfs support.

How to Configure for BIOS-based PXE Clients

  1. Install the syslinux package that contains the pxelinux.0 boot loader.
    sudo dnf install syslinux -y
  2. Create the pxelinux/pxelinux.cfg directory under the TFTP server directory.
    sudo mkdir -p /var/lib/tftpboot/pxelinux/pxelinux.cfg
  3. Copy the boot loader file to the pxelinux subdirectory.
    sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux
  4. From the NFS share directory, copy the installation kernel (vmlinuz), and the ram-disk image file (initrd.img) to the pxelinux subdirectory.
    sudo cp /var/nfs-exports/ISOs/ol9/vmlinuz /var/lib/tftpboot/pxelinux/vmlinuz
    sudo cp /var/nfs-exports/ISOs/ol9/initrd.img /var/lib/tftpboot/pxelinux/initrd.img
  5. Copy the modules for displaying the boot loader as a menu to the boot loader directory.
    sudo cp /usr/share/syslinux/*.c32 /var/lib/tftpboot/pxelinux
  6. In the pxelinux.cfg subdirectory, create and add entries to a boot configuration file.
    You can assign any name to the file, such as pxe.conf. The following example shows typical entries in the file:
    DEFAULT menu.c32
    TIMEOUT 400
    ONTIMEOUT BootLocal
    PROMPT 0
    MENU INCLUDE pxelinux.cfg/pxe.conf
    NOESCAPE 1
    LABEL BootLocal
        localboot 0
        TEXT HELP
        Boot to local hard disk
        ENDTEXT
    
    LABEL OL9
        MENU LABEL OL9 
        kernel vmlinuz
        append initrd=initrd.img inst.repo=/var/nfs-exports/ISOs/ol9/ \
        inst.ks.sendmac inst.ks=/var/nfs-exports/ISOs/ksfiles/kstart-file
        TEXT HELP
        Install Oracle Linux 9   
        ENDTEXT

    Based on these entries, the boot loader would automatically attempt to boot from the local drive if no user intervention occurs during the TIMEOUT period. If no OS is installed, then the boot loader would boot from the network and initiate the installation process.

    This list explains some directives used in the configuration file:

    • DEFAULT identifies the module you want to use for displaying the boot loader menu.

      For a basic text display, the menu.c32 module suffices. However, if you add directives for a graphical display, such as images and colors, then specify the vesamenu.c32 module instead.

    • TIMEOUT specifies the period in timeout/10 seconds before the boot loader boots the client according to the subsequent directives. The next directive (ontimeout) specifies the action when the wait period expires.

    • PROMPT determines whether the boot: prompt is displayed by default. If PROMPT is set to 1, the boot: prompt is displayed. If PROMPT is set to 0, the boot: prompt isn't displayed unless the user presses the Shift or Alt key at the console.

    • MENU INCLUDE identifies the boot configuration file you created.

    • kernel defines the name of the kernel executable.

    • append defines any parameters to append when loading the kernel, such as the name of the ram-disk image and the location of a file. Note that the inst.repo variable can be set to point to the BaseOS repository on the Oracle Linux yum server if the system has access to the Internet. For example, inst.repo can be set to https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64 for an x86_64 platform system.

      Important:

      The kernel and ram-disk image file paths are assumed to be relative to the subdirectory that contains the boot loader, such as pxelinux. If you place the vmlinuz and initrd.img files in a subdirectory such as pxelinux/OL9, ensure you have the correct relative paths.

How to Configure for UEFI-based PXE Clients

  1. Download the grub2-efi and shim packages:
    mkdir /tmp/boot_rpms
    sudo dnf download shim grub2-efi --downloaddir=/tmp/boot_rpms
  2. Go to the package location and extract their contents:
    cd /tmp/boot_rpms
    sudo rpm2cpio grub2-efi-version.rpm | cpio -idmv 
    sudo rpm2cpio shim-version.rpm | cpio -idmv
  3. Create a subdirectory, for example, efi, under the TFTP server directory:
    sudo mkdir -p /var/lib/tftpboot/efi
  4. Copy the boot loader and other related files to the efi subdirectory:
    sudo cp /tmp/boot_rpms/boot/efi/EFI/redhat/grubx64.efi /var/lib/tftpboot/efi
    sudo cp /tmp/boot_rpms/boot/efi/EFI/redhat/shim*.efi /var/lib/tftpboot/efi
    sudo cp /tmp/boot_rpms/boot/efi/EFI/redhat/MokManager.efi /var/lib/tftpboot/efi

    Note:

    The shim.efi and MokManager.efi files are needed to support Secure Boot on clients. The MokManager.efi provides utilities for managing the keys used to sign EFI binaries. As a passthrough boot loader, you would then specify shim.efi when setting dhcp-boot for UEFI-based clients in the /etc/dnsmasq.conf file. See How to Configure dnsmasq.

  5. From the NFS share directory, copy the installation kernel (vmlinuz) and the ram-disk image file (initrd.img) to the efi subdirectory.
    sudo cp /var/nfs-exports/ISOs/ol9/vmlinuz -O /var/lib/tftpboot/efi/vmlinuz
    sudo cp /var/nfs-exports/ISOs/ol9/initrd.img /var/lib/tftpboot/efi/initrd.img
  6. In the efi subdirectory, create and then add entries to the grub.cfg boot loader configuration file.

    The configuration file includes the options for booting from the network and for booting locally. The client boots from the network to begin the installation process. Then after the client reboots at the end of the installation, the system boots from the local drive.

    The following example shows typical entries in the file:

    set default 0
    set timeout=10
    
    menuentry 'ol9 localboot' {
    echo "Booting from local disk"
    set root=(hd0,gpt1)
    chainloader efi/shim.efi
    boot
    }
    
    menuentry 'ol9' {
      echo "Loading vmlinuz"
      linuxefi vmlinuz inst.repo=/var/nfs-exports/ISOs/ol9/ inst.ks.sendmac \
      inst.ks=/var/nfs-exports/ISOs/ksfiles/kstart-file
      echo "Loading /initrd.img"
      initrdefi initrd.img
      echo "Booting installation kernel"
    }

    Caution:

    Boot loader configuration isn't uniform across UEFI-based systems. Because of variables such as differing disk layout, a specific boot loader setup does'nt universally apply to all systems. The previous example illustrates only one way of configuring the boot loader. You must create boot loader configurations appropriate to the systems that you're setting up.

    • linuxefi defines the name of the kernel executable and any parameters to append when loading the kernel, such as the location of the installation packages and the location of a file.

    • initrdefi defines the name of the ram-disk image.

    Important:

    The kernel and ram-disk image file paths are assumed to be relative to the subdirectory that contains the boot loader, such as efi. If you place the vmlinuz and initrd.img files in a subdirectory, such as efi/OL9, ensure you have the correct relative paths.