Customizing the AlmaLinux Installer Media

This article shows you how to customize the AlmaLinux (or Red Hat Enterprise Linux, or Rocky Linux, or CentOS Linux) installer media to include a kickstart file and additional file assets.

Conventions

Commands run as root will appear on a black background:

cd ~

Commands run as your regular user will appear on a grey background:

cd ~

Prerequisites

  • A basic AlmaLinux workstation installation (temporary is fine).
  • The Alma Linux boot ISO in your user home directory.
  • A kickstart file in your user home directory (~/ks.cfg). Kickstart files are a complicated topic warranting their own article and are not detailed here.
  • An Assets subdirectory of your user home directory containing any additional files you want to be available during installation (wallpapers, configuration files, etc.)

Steps

Install required packages.

dnf install createrepo genisoimage isomd5sum syslinux

Create a directory to mount the AlmaLinux ISO.

mkdir /mnt/almalinux

Create a working directory.

mkdir ~/almalinux-custom

Mount the ISO.

mount -o loop ~/AlmaLinux-8.5-x86_64-boot.iso /mnt/almalinux

Copy the ISO contents to a working directory.

rsync -av --progress /mnt/almalinux/ ~/almalinux-custom/

Unmount the ISO.

umount /mnt/almalinux

Copy the kickstart file.

cp ~/ks.cfg ~/almalinux-custom/

Copy the Assets directory to the root of the custom ISO and update the metadata.

cp -r ~/Assets ~/almalinux-custom/
createrepo -dpo ~/almalinux-custom ~/almalinux-custom/Assets/

Add kickstart to boot options to grub.cfg for UEFI boot and modify the boot order. Remove the strikethrough items and add the bold items.

vi ~/almalinux-custom/EFI/BOOT/grub.cfg
set default="1"
set default="0"

set timeout=60
set timeout=0

​​​​​​​menuentry 'Install AlmaLinux 8' --class fedora --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=AlmaLinux-8-5-x86_64-dvd quiet inst.text inst.ks=cdrom:/ks.cfg inst.stage2=hd:LABEL=AlmaLinux-8-5-x86_64-custom
        initrdefi /images/pxeboot/initrd.img

Add kickstart options to isolinux.cfg for legacy BIOS boot and modify boot order. Remove the strikethrough items and add the bold items.

vi /mnt/almalinux-custom/isolinux/isolinux.cfg
​​​​​​​timeout 600
timeout 0

l​​​​​​​abel linux

  menu label ^Install AlmaLinux 8
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=AlmaLinux-8-5-x86_64-dvd quiet inst.text inst.ks=cdrom:/ks.cfg inst.stage2=hd:LABEL=AlmaLinux-8-5-x86_64-custom

Create the custom ISO. Note: The label (-V) must match the inst.stage2=hd:LABEL in grub.cfg and isolinux.cfg (above).

mkisofs -o /mnt/hgfs/data/AlmaLinux-8.5-x86_64-custom.iso -b isolinux/isolinux.bin -J -R -l -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -graft-points -V "AlmaLinux-8-5-x86_64-custom" /mnt/almalinux-custom/

Use isohybrid to enable writing to USB devices.

isohybrid --uefi ~/AlmaLinux-8.5-x86_64-custom.iso

Use implantisomd5 to add the MD5 checksum.

implantisomd5 ~/AlmaLinux-8.5-x86_64-custom.iso