Configure PXE Boot Server for Rocky Linux 9/CentOS 9 Kickstart Installation

Preparing to migrate homelab infrastructure from Rocky 8 to Rocky 9.

Pre-requisites

We are using our existing PXE boot homelab server in this article.

All commands to be run on the PXE boot server.

Download and Create Rocky Linux 9 FTP Installation Media

Download the latest DVD version of Rocky Linux 9 ISO image.

$ sudo yum install curl -y
$ curl -# -O https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-9-latest-x86_64-dvd.iso

Mount the image and copy its content to the FTP location:

$ sudo mkdir -p /mnt/iso /var/ftp/pub/pxe/Rocky9
$ sudo mount Rocky-9-latest-x86_64-dvd.iso /mnt/iso
$ sudo cp -prv /mnt/iso/* /var/ftp/pub/pxe/Rocky9/
$ sudo umount /mnt/iso

Verify:

$ curl ftp://localhost/pub/pxe/Rocky9/
drwxr-xr-x    4 0        0              38 May 14 19:16 AppStream
drwxrwxr-x    4 0        0              38 May 14 19:42 BaseOS
-rw-r--r--    1 0        0            5504 Jun 21 08:59 COMMUNITY-CHARTER
-rw-r--r--    1 0        0            1394 Jun 21 08:59 Contributors
drwxrwxr-x    3 0        0              18 May 12 00:24 EFI
-rw-r--r--    1 0        0             372 Jun 21 08:59 EULA
-rw-r--r--    1 0        0            2204 Jun 21 08:59 LICENSE
-rw-r--r--    1 0        0            1750 Jun 21 08:59 RPM-GPG-KEY-Rocky-9
-rw-r--r--    1 0        0            3159 Jun 21 08:59 RPM-GPG-KEY-Rocky-9-Testing
drwxrwxr-x    3 0        0              59 May 12 00:24 images
drwxrwxr-x    2 0        0             239 May 12 00:24 isolinux
-rw-r--r--    1 0        0             102 Jun 21 09:00 media.repo

Create Rocky Linux Kickstart File

This is the Packer kickstart file /var/ftp/pub/pxe/rocky9-packer-ks.cfg that I use for my Rocky Linux 9 Kubernetes servers (a 32GB disk required).

#version=RHEL9
# This file was generated using the Kickstart Generator page, see below:
# https://access.redhat.com/labs/kickstartconfig/

# Use network installation
url --url="ftp://10.11.1.20/pub/pxe/Rocky9/BaseOS"
repo --name="AppStream" --baseurl="ftp://10.11.1.20/pub/pxe/Rocky9/AppStream"
# Disable Initial Setup on first boot
firstboot --disable

# Use text mode install
text
# Keyboard layouts
keyboard --vckeymap=gb --xlayouts='gb'
# System language
lang en_GB.UTF-8
# SELinux configuration
selinux --enforcing
# Firewall configuration
firewall --enabled --ssh
# Do not configure the X Window System
skipx

# Network information
network --bootproto=dhcp --device=eth0 --nameserver=10.11.1.2,10.11.1.3 --noipv6 --activate
network --hostname=rocky9.localdomain

# System authorisation information
auth --useshadow --passalgo=sha512
# Root password
rootpw packer
# Root SSH public key
sshkey --username=root "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzcZWKJVeDTioSe5x1M7WdNGgX4HQsZQeP92zK2LlP7vymnzts/IZz4I5r6Z0WwSMh9VxN9IABxsotdohiC9kroEdqUG9/OmljQhHNXnMOlAhnofJAnnEb7Tr1v1xGJllpQ135PNL+ECTIslQMBD68a2WZGLvJBPg/WSEsaD6oWwVnrldXIolvDaAKx3TnipwoEp/jcZ1KXTA6LuqdpG1XDI35pT8QF9bO79nv05nf9ypynJxMZZ66HcwiKnoNbyY/Xa2b1Yyv5WA+2kY821bKMaYiKRuwABZI/1M5kLLki6RZ9rvUG8FfiJVhhAJXOIguT1reBdQsBfxqLirotf2t8kOzGbKwwXIPqePtTlCFe0GKT5H6qe1x1kXBPF4+m2r2JPllhwcnNtPl5MVn9X/HQSDRgYtTPlXREuyLLWD1n4vpcka6YMrCulE9KJmnN1J++rRGLgeU47/lgFwKOfF0yugMyfTTrbYUffzBDBsV8mSelra/sm4ZwrkjOzNiSStUAHZ6WL4t2vNs94B61eVKHMFKFSbFKeQ79qEisJkQp4pOUJDmNohMZKquNThrwX5qhVsNFJ28mZfYvJrxn+ha2M3by9+WealubGy14FFGz5Ir7UWmL8IsB5Bq+USwiVxOy+TBecMUNyuy5H0ttX7gbkvo3mRF9h4apfcFlxtZlQ== [email protected]"
# System timezone
timezone Europe/London --utc

ignoredisk --only-use=vda
# System bootloader configuration
bootloader --location=mbr --timeout=1 --boot-drive=vda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Reboot after installation
reboot

# Disk partitioning information
#autopart --type=lvm
part /boot --fstype="xfs" --ondisk=vda --size=1024 --label=boot --asprimary --fsoptions="rw,nodev,noexec,nosuid"
part pv.01 --fstype="lvmpv" --ondisk=vda --size=31743
volgroup vg_os pv.01
logvol /tmp  --fstype="xfs" --size=1024 --label="lv_tmp" --name=lv_tmp --vgname=vg_os --fsoptions="rw,nodev,noexec,nosuid"
logvol /  --fstype="xfs" --size=30716 --label="lv_root" --name=lv_root --vgname=vg_os

%packages
# dnf group info minimal-environment
@^minimal-environment
sudo
qemu-guest-agent
openssh-server
# Alsa not needed in a VM
-alsa*
# Microcode updates cannot work in a VM
-microcode_ctl
# Firmware packages are not needed in a VM
-iwl*firmware
# Don't build rescue initramfs
-dracut-config-rescue
-plymouth
%end

%addon com_redhat_kdump --disable --reserve-mb='auto'
%end

%post 
sed -i 's/^.*requiretty/#Defaults requiretty/' /etc/sudoers
sed -i 's/rhgb //' /etc/default/grub
# SSHD PermitRootLogin and enable the service
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
/usr/bin/systemctl enable sshd
# Update all packages
/usr/bin/yum -y update
%end

Copy the content and save it as /var/ftp/pub/pxe/rocky9-packer-ks.cfg on the PXE boot server.

Copy initrd.img and vmlinuz from the Rocky Linux 9 installation media to /var/lib/tftpboot/networkboot/Rocky9/:

$ sudo mkdir -p /var/lib/tftpboot/networkboot/Rocky9
$ sudo cp -pv /var/ftp/pub/pxe/Rocky9/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/networkboot/Rocky9/

Update the PXE boot configuration file /var/lib/tftpboot/pxelinux.cfg/default with the following content:

default menu.c32
prompt 0
timeout 50
menu title Homelab PXE Menu
label Install Rocky Linux 9 Server (Packer kickstart, no swap)
  kernel /networkboot/Rocky9/vmlinuz
  append initrd=/networkboot/Rocky9/initrd.img inst.repo=ftp://10.11.1.20/pub/pxe/Rocky9 inst.ks=ftp://10.11.1.20/pub/pxe/rocky9-packer-ks.cfg

Perform a Network Boot

Create a VM that uses Network Boot (PXE), start it and check the automated process.

8 thoughts on “Configure PXE Boot Server for Rocky Linux 9/CentOS 9 Kickstart Installation

  1. hi,

    Little typo in the below section – line 1 you have /Rocky8, line 4 /Rocky9.

    Mount the image and copy its content to the FTP location:

    $ sudo mkdir -p /mnt/iso /var/ftp/pub/pxe/Rocky8
    $ sudo mount Rocky-9.2-x86_64-dvd.iso /mnt/iso
    $ sudo cp -prv /mnt/iso/* /var/ftp/pub/pxe/Rocky9/
    $ sudo umount /mnt/iso

    • That’s a good point if you’re testing from the same machine where the FTP server is running on. I’ve updated the article, thank you!

  2. Bellow four lines are missing in “/var/lib/tftpboot/pxelinux.cfg/default” file.
    default menu.c32
    prompt 0
    timeout 30
    menu title Homelab PXE Menu

    • Thanks. I did not mean to provide the full content of the file, just the lines related to Rocky 9, apologies if this caused confusion.

      For those interested, this is how the file /var/lib/tftpboot/pxelinux.cfg/default looks like on my PXE server:

      default menu.c32
      prompt 0
      timeout 50
      menu title Homelab PXE Menu
      label Install Rocky 9 Server (Packer kickstart, no swap)
        kernel /networkboot/Rocky9/vmlinuz
        append initrd=/networkboot/Rocky9/initrd.img inst.repo=ftp://10.11.1.20/pub/pxe/Rocky9 inst.ks=ftp://10.11.1.20/pub/pxe/rocky9-packer-ks.cfg
      label Install Rocky 8 Server (Packer kickstart, no swap)
        kernel /networkboot/Rocky8/vmlinuz
        append initrd=/networkboot/Rocky8/initrd.img inst.repo=ftp://10.11.1.20/pub/pxe/Rocky8 inst.ks=ftp://10.11.1.20/pub/pxe/rocky8-packer-ks.cfg
      label Install Rocky 9 Server (host kickstart 240GB sda, swap)
        kernel /networkboot/Rocky9/vmlinuz
        append initrd=/networkboot/Rocky9/initrd.img inst.repo=ftp://10.11.1.20/pub/pxe/Rocky9 inst.ks=ftp://10.11.1.20/pub/pxe/rocky9-host-ks.cfg
      label Install Rocky 8 Server (host kickstart 240GB sda, swap)
        kernel /networkboot/Rocky8/vmlinuz
        append initrd=/networkboot/Rocky8/initrd.img inst.repo=ftp://10.11.1.20/pub/pxe/Rocky8 inst.ks=ftp://10.11.1.20/pub/pxe/rocky8-host-ks.cfg
      label Install Ubuntu 20.04 LTS Server
        kernel /networkboot/Ubuntu2004Server/linux
        append initrd=/networkboot/Ubuntu2004Server/initrd.gz ks=nfs:10.11.1.20:/var/nfs/Ubuntu2004Server/preseed/ubuntu2004-server.seed ---
      label Install Ubuntu 20.04 LTS Desktop
        kernel /networkboot/Ubuntu2004Desktop/linux
        append initrd=/networkboot/Ubuntu2004Desktop/initrd.gz ks=nfs:10.11.1.20:/var/nfs/Ubuntu2004Desktop/preseed/ubuntu2004-desktop.seed ---
      label Install Ubuntu 18.04 LTS Server
        kernel /networkboot/Ubuntu1804Server/linux
        append initrd=/networkboot/Ubuntu1804Server/initrd.gz ks=nfs:10.11.1.20:/var/nfs/Ubuntu1804Server/preseed/ubuntu1804-server.seed ---
      label Install Ubuntu 18.04 LTS Desktop
        kernel /networkboot/Ubuntu1804Desktop/linux
        append initrd=/networkboot/Ubuntu1804Desktop/initrd.gz ks=nfs:10.11.1.20:/var/nfs/Ubuntu1804Desktop/preseed/ubuntu1804-desktop.seed ---
      
  3. I have followed these instructions. I don’t have a /var/lib/tftpboot/pxelinux.cfg/default file. I don’t even have a /var/lib/tftpboot/pxelinux.cfg directory. What is going on? Rocky 9.4

Leave a Reply

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