Customizing a Red Hat or CentOS Linux bootable ISO

RHEL and CentOS ship bootable CDs or DVDs in the ISO file format. It is possible to modify these ISO files with various types of customizations, e.g by adding additional boot menu items or an automated kickstart installation. This article contains a step-by-step guide how to customize and repackage a bootable CentOS ISO.

Prerequisites:

  • something to extract files from an ISO image (e.g. mount as a loop device or use bsdtar)
  • mkisofs tool to genereate a bootable ISO image (genisoimage or cdrtools)

Step-by-step guide:

  1. Download the CentOS or RHEL ISO file. In our example, we will use the netinstall ISO.
    Get the CentOS ISO from a CentOS mirror

    wget http://ftp.fau.de/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-NetInstall-1804.iso
  2. Create a working directory
    mkdir centos_netinstall
  3. Extract ISO contents into the working directory
    bsdtar -x -C centos_netinstall -f CentOS-7-x86_64-NetInstall-1804.iso
  4. Modify or add new files to the working directory
    EFI boot configuration is located in EFI/BOOT/grub.cfg
    ISOLINUX boot configuration is located in isolinux/isolinux.cfg

  5. Create a new bootable ISO with mkifofs
    mkisofs -r -T -J -V "CentOS 7 x86_64" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o centos7_customized.iso centos_netinstall

    The volume name after the -V flag must match the volume name used in EFI/BOOT/grub.cfg and isolinux/isolinux.cfg. The “\x20” character is a whitespace.
    The last argument to mkisofs is the name of the installation directory.

Example for a configuration entry with automated kickstart install:

EFI/BOOT/grub.cfg:
menuentry 'Kickstart CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/kickstart.cfg ksdevice=bootif nostorage
initrdefi /images/pxeboot/initrd.img
}
isolinux/isolinux.cfg:
label kickstart
menu label ^Kickstart CentOS 7
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet inst.ks=hd:LABEL=CentOS\x207\x20x86_64:/kickstart.cfg ksdevice=bootif nostorage

To make the kickstart menu entry start by default, it has to be configured in both files:

  • EFI/BOOT/grub.cfg: reference the correct menu item position in the first line: set default=”1″. The boot menu timeout may be changed by modifying the set timeout=60 line.
  • isolinux/isolinux.cfg: add menu default to the new kickstart label and remove it from any other menu items. The boot menu timeout is defined in the second line timeout 600.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>