How to create a modified Red Hat Enterprise Linux ISO with kickstart file or modified installation media?

Solution Verified - Updated

Environment

Issue

  • How to create a customized or modified Red Hat Enterprise Linux 6/7/8/9 ISO with kickstart file included in the ISO?
  • How to include a kickstart file in ISO image and create customized ISO?

Resolution


DISCLAIMER: The following information has been provided by Red Hat, but is outside the scope of the posted Service Level Agreements and support coverage. The information is provided as-is and any configuration settings or installed applications made from the information in this article could make the Operating System unsupported by Red Hat Global Support Services. The intent of this article is to provide information to accomplish the system's needs. Use of the information in this article at your own risk.

Red Hat does NOT support the modification or customization of RHEL installation media. For customizing OS images(system template, live CD, etc.), you can utilize kickstart to build consistent systems in your infrastructure or use the RHEL Image Builder to create custom OS images. This article is provided as a how-to and Red Hat will not be able to support the process described here.


NOTES:

  • These procedures are applicable for x86_64 architecture only. Steps may differ for other architectures.

  • RHEL 8 and RHEL 9 come with the mkksiso tool (a part of the lorax package) that allows implementing a kickstart file to an ISO file. It is usable on all architectures.

  • Red Hat recommends using a OEMDRV ISO image (or disk in general), which can contain a kickstart stored as /ks.cfg and doesn't require rebuilding the official DVD

    $ mkdir OEMDRV
    $ cat > OEMDRV/ks.cfg << EOF
    # This is my kickstart
    # ...
    EOF
    $ mkisofs -V OEMDRV -o OEMDRV.iso OEMDRV
    

FOR RED HAT ENTERPRISE LINUX 10

RHEL 10 uses grub2 bootloader for both BIOS and UEFI while in earlier version syslinux bootloader was used for booting the ISO through BIOS so the steps to rebuild the ISO are different.

This example show how to rebuild the rhel-10.0-x86_64-dvd.iso DVD with the Kickstart file.

  1. Download the tools required for this process.

    # dnf install isomd5sum xorriso lorax
    
  2. Extract the DVD iso to /tmp/rhel10 or any other directory

    Make sure to setup the environment variable relative to the extracted path, e.g.:

    # export DVDDIR=/tmp/rhel10
    
  3. Copy the kickstart file

    # cd $DVDDIR
    # cp /PATH/TO/CREATED/ks.cfg $DVDDIR
    
  4. In RHEL 10 we don't have isolinux.cfg file (which was present in previous versions of RHEL that used syslinux bootloader) , now since grub bootloader is used for both BIOS and UEFI, we have BIOS grub configuration present at boot/grub2/grub.cfg.
    Note the boot entry and the DVD LABEL which will be used in next steps.

    # grep -m 1 -A 3 "Install Red Hat" $DVDDIR/boot/grub2/grub.cfg
    menuentry 'Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
    	linux /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-10-0-BaseOS-x86_64 quiet
    	initrd /images/pxeboot/initrd.img
    }
    

    Here, above the LABEL for the DVD is RHEL-10-0-BaseOS-x86_64

  5. Add new boot entry to the BIOS grub configuration boot/grub2/grub.cfg by copying the previous entry and modifying it to include the new name and inst.ks=hd:LABEL=RHEL-10-0-BaseOS-x86_64:/ks.cfg directive.

    menuentry 'Kickstart Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
    	linux /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-10-0-BaseOS-x86_64 quiet inst.ks=hd:LABEL=RHEL-10-0-BaseOS-x86_64:/ks.cfg
    	initrd /images/pxeboot/initrd.img
    }
    
  6. The same steps will apply for the UEFI grub configuration file EFI/BOOT/grub.cfg, first note the previous entry.

    # grep -m 1 -A 3 "Install Red Hat" $DVDDIR/EFI/BOOT/grub.cfg
    menuentry 'Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
    	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-10-0-BaseOS-x86_64 quiet
    	initrdefi /images/pxeboot/initrd.img
    }
    
  7. Add new boot entry to the UEFI grub configuration by copying the previous entry and modifying it to include new name and inst.ks=hd:LABEL=RHEL-10-0-BaseOS-x86_64:/ks.cfg directive

    menuentry 'Kickstart Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
    	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-10-0-BaseOS-x86_64 quiet inst.ks=hd:LABEL=RHEL-10-0-BaseOS-x86_64:/ks.cfg
    	initrdefi /images/pxeboot/initrd.img
    }
    
  8. Rebuild the EFI Boot Image using mkefiboot command.

    # mkefiboot --label=ANACONDA $DVDDIR/EFI/BOOT/ $DVDDIR/images/efiboot.img
    
  9. Finally rebuild the ISO using xorrisofs making sure that -V option has correct label. The LABEL noted in step 4 is being reused here RHEL-10-0-BaseOS-x86_64

    # cd $DVDDIR
    # xorrisofs -o /tmp/RHEL10-Kickstart.iso -R -J -V RHEL-10-0-BaseOS-x86_64 --grub2-mbr $DVDDIR/boot/grub2/i386-pc/boot_hybrid.img -partition_offset 16 -appended_part_as_gpt -append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B $DVDDIR/images/efiboot.img -iso_mbr_part_type EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 -c boot.cat --boot-catalog-hide -b images/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info -eltorito-alt-boot -e --interval:appended_partition_2:all:: -no-emul-boot -graft-points  .
    

    Note: Mind that there is a dot '.' at the end of the xorrisofs command.
    Note: if building the ISO on RHEL8, replace C12A7328-F81F-11D2-BA4B-00A0C93EC93B by 0xef and EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 by 0x83.

  10. Implant the MD5 checksum inside the ISO.

    # implantisomd5 /tmp/RHEL10-Kickstart.iso
    

FOR RED HAT ENTERPRISE LINUX 7 & 8 & 9

In this example, we will rebuild a RHEL 7.9 Server DVD.

  1. Extract the DVD iso to /tmp/rhel79 or any other directory

    Make sure to setup the environment variable relative to the extracted path, e.g.:

    # export DVDDIR=/tmp/rhel79
    
  2. Get the kickstart file and rename it to ks.cfg

    # cd $DVDDIR
    # cp /PATH/TO/CREATED/ks.cfg $DVDDIR
    
  3. Note down the linux boot entry of the DVD along with the DVD label

    # grep -A4 "^label linux" $DVDDIR/isolinux/isolinux.cfg 
    label linux
      menu label ^Install Red Hat Enterprise Linux 7.9
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 quiet
    

    Here above the label for the DVD is "RHEL-7.9 Server.x86_64" (the space is replaced by "\x20" in the boot entry).

  4. Add the new boot entry to $DVDDIR/isolinux/isolinux.cfg by copy/pasting/renaming the linux boot entry (previous step) and appending inst.ks directive:

    label kickstart
      menu label ^Kickstart Install Red Hat Enterprise Linux 7.9
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 quiet inst.ks=cdrom:/ks.cfg
    

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

  5. Similarly, note down the first boot entry when booting in UEFI

    $ grep -m 1 -A3 "Install Red Hat Enterprise Linux" $DVDDIR/EFI/BOOT/grub.cfg
    menuentry 'Install Red Hat Enterprise Linux 7.9' --class fedora --class gnu-linux --class gnu --class os {
    	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 quiet
    	initrdefi /images/pxeboot/initrd.img
    }
    
  6. Add the new boot entry to $DVDDIR/EFI/BOOT/grub.cfg by copy/pasting/renaming the content of previous step and appending inst.ks directive:

    menuentry 'Kickstart Install Red Hat Enterprise Linux 7.9' --class fedora --class gnu-linux --class gnu --class os {
    	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 quiet inst.ks=cdrom:/ks.cfg
    	initrdefi /images/pxeboot/initrd.img
    }
    

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

  7. Finally rebuild the ISO, making sure that -V option has the correct label, or the DVD won't be booting properly

    # cd $DVDDIR
    # mkisofs -o /tmp/rhel79test.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 "RHEL-7.9 Server.x86_64" .
    # isohybrid --uefi /tmp/rhel79test.iso
    # implantisomd5 /tmp/rhel79test.iso
    

    Notes:

    • The only difference for Red Hat Enterprise Linux 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 RHEL9, the isohybrid command is not available and it's not required; use the following mkisofs command instead:

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

FOR RED HAT ENTERPRISE LINUX 6 & 5

  1. Extract the DVD iso to /newiso:

  2. Copy the kickstart file ks.cfg in the /newiso/ directory

     # cp /path/to/ks.cfg /newiso/
    
  3. Now make /newiso/isolinux/isolinux.cfg file writable and make changes in it.

     # cd /newiso/
     # chmod a+w EFI/BOOT/BOOTX64.conf
     # vi EFI/BOOT/BOOTX64.conf
    
  4. Make necessary changes as required, like provide the kickstart file path or any other kernel command line parameters too. One can place the driverdisk here as well. E.g

     title Red Hat Enterprise Linux 6.10 Kickstart
     	kernel /images/pxeboot/vmlinuz ks=cdrom:/ks.cfg <additional anaconda boot parameters>
     	initrd /images/pxeboot/initrd.img 
    
  5. In case one want to make it bootable with Kickstart for Legacy too, please make an additional change in isolinux/isolinux.cfg as follows.

     label linux
       menu label ^Install using Kickstart File
       menu default
       kernel vmlinuz
       append initrd=initrd.img ks=cdrom:/ks.cfg <additional anaconda boot parameters>
    
  6. Make the file EFI/BOOT/BOOTX64.conf read only again.

     # chmod a-w EFI/BOOT/BOOTX64.conf
    
  7. Create the ISO file.

     # cd /newiso
    
     # mkisofs -o /tmp/test.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 disks /newiso .
    
     # isohybrid --uefi /tmp/test.iso
    
    • After running the above command, the file /tmp/test.iso will be created which will be bootable and by default kickstart installation DVD iso. Just hit Enter to install using kickstart file ks.cfg which is available into the DVD iso.

FOR CUSTOMIZING OS IMAGES WITH IMAGE BUILDER


[RHEL 9 Image Builder Guide](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/composing_a_customized_rhel_system_image/index)
[RHEL 8 Image Builder Guide](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/composing_a_customized_rhel_system_image/index)
[RHEL 7 Image Builder Guide](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/image_builder_guide/index)
SBR
Components

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.