Home / How to create a modified CentOS / AlmaLinux ISO with kickstart file or modified installation media?

How to create a modified CentOS / AlmaLinux ISO with kickstart file or modified installation media?

These steps will only work for the x86_64 system. For other systems, the steps may be different.

The mkksiso tool, which is part of the lorax package and comes with CentOS 8 and CentOS 9, lets you add a kickstart file to an ISO file. All systems can use it.

Purchase Dedicated Servers

Select, configure, and buy!

For CentOS 9, 8, 7

Mount the DVD iso at some location.

# mount -o loop /PATH/TP/DOWNLOADED/centos-server-7.9-x86_64-dvd.iso /mnt

Then create a directory and copy all the contents of theISO into the same.

# shopt -s dotglob
# mkdir /tmp/centos79
# cp -avRf /mnt/* /tmp/centos79

The hidden files should be copied as well. After enabling a dotglob option, '*' includes dot files too. If a ISO image does not include .discinfo, the disk's stage2 won't load, and the customized image won't be of any use for installation purpose.

Verify that all hidden files like .treeinfo are there in /tmp/centos79

# cd /tmp/centos79
# ls -a
Get the kickstart file and rename it toks.cfg
# cd /tmp/centos79
# cp /PATH/TO/CREATED/ks.cfg /tmp/centos79/
Note down the linux boot entry of the DVD along with the DVD label
# grep -A4 "^label linux" /tmp/centos79/isolinux/isolinux.cfg 
label linux
menu label ^Install CentOS Linux 7.9
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS-7.9\x20Server.x86_64 quiet
Here above the label for the DVD is "CENTOS-7.9 Server.x86_64" (the space is replaced by "\x20" in the boot entry).
Add the new boot entry to /tmp/centos79/isolinux/isolinux.cfg by copying, pasting, renaming, and adding the inst.ks command to the linux boot entry.
label kickstart
menu label ^Kickstart Install CentOS Linux 7.9
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS-7.9\x20Server.x86_64 quiet inst.ks=cdrom:/ks.cfg
If you are making a USB, you want to use "inst.ks=hd:LABEL=CENTOS-7.9\x20Server.x86_64:/ks.cfg" instead of targeting the CDROM. Also, when starting in UEFI, write down the first boot entry.
$ grep -m 1 -A3 "Install CENTOS Linux" /tmp/centos79/EFI/BOOT/grub.cfg
menuentry 'Install CentOS Linux 7.9' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CENTOS-7.9\x20Server.x86_64 quiet
initrdefi /images/pxeboot/initrd.img
}
Add the new boot entry to /tmp/centos79/EFI/BOOT/grub.cfg by copy/pasting/renaming the content of previous step and appending inst.ks directive:
menuentry 'Kickstart Install CentOS Linux 7.9' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CENTOS-7.9\x20Server.x86_64 quiet inst.ks=cdrom:/ks.cfg
initrdefi /images/pxeboot/initrd.img
}

If you are making a USB, you will want to use "inst.ks=hd:LABEL=CENTOS-7.9\x20Server.x86_64:/ks.cfg" instead of targeting the CDROM.

Last, rebuild the ISO and make sure that the -V option has the correct name. If it doesn't, the DVD won't start up correctly.
# cd /tmp/centos79/
# mkisofs -o /tmp/centos79test.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 -joliet-long -V "CENTOS-7.9 Server.x86_64" .
# isohybrid --uefi /tmp/centos79test.iso
# implantisomd5 /tmp/centos79test.iso

The only difference for CentOS 8 will be the kickstart file and the Volume LABEL.

Mind that there's a dot '.' at the end of the mkisofs command.

For 64-bit ARM in CENTOS9, the isohybrid command is not available and it's not required; use the following mkisofs command instead.

# mkisofs -o /tmp/centos9test-aarch64.iso -J -R -l -c boot.catalog -no-emul-boot -e images/efiboot.img -V "CENTOS-9-0-0-BaseOS-aarch64" .

Purchase Dedicated Servers

Select, configure, and buy!

Leave a Reply