How to create a modified Red Hat Enterprise Linux ISO with kickstart file or modified installation media?
Environment
- Red Hat Enterprise Linux (RHEL) 6
- Red Hat Enterprise Linux (RHEL) 7
- Red Hat Enterprise Linux (RHEL) 8
- Red Hat Enterprise Linux (RHEL) 9
- Red Hat Enterprise Linux(RHEL) 10
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
kickstartfile 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_64architecture only. Steps may differ for other architectures. -
RHEL 8 and RHEL 9 come with the
mkksisotool (a part of theloraxpackage) 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.cfgand 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.
-
Download the tools required for this process.
# dnf install isomd5sum xorriso lorax -
Extract the DVD iso to
/tmp/rhel10or any other directoryMake sure to setup the environment variable relative to the extracted path, e.g.:
# export DVDDIR=/tmp/rhel10 -
Copy the kickstart file
# cd $DVDDIR # cp /PATH/TO/CREATED/ks.cfg $DVDDIR -
In RHEL 10 we don't have
isolinux.cfgfile (which was present in previous versions of RHEL that usedsyslinuxbootloader) , now since grub bootloader is used for both BIOS and UEFI, we have BIOS grub configuration present atboot/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 -
Add new boot entry to the BIOS grub configuration
boot/grub2/grub.cfgby copying the previous entry and modifying it to include the new name andinst.ks=hd:LABEL=RHEL-10-0-BaseOS-x86_64:/ks.cfgdirective.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 } -
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 } -
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.cfgdirectivemenuentry '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 } -
Rebuild the EFI Boot Image using
mkefibootcommand.# mkefiboot --label=ANACONDA $DVDDIR/EFI/BOOT/ $DVDDIR/images/efiboot.img -
Finally rebuild the ISO using
xorrisofsmaking sure that -V option has correct label. TheLABELnoted in step 4 is being reused hereRHEL-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
xorrisofscommand.
Note: if building the ISO on RHEL8, replaceC12A7328-F81F-11D2-BA4B-00A0C93EC93Bby0xefandEBD0A0A2-B9E5-4433-87C0-68B6B72699C7by0x83. -
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.
-
Extract the DVD iso to
/tmp/rhel79or any other directoryMake sure to setup the environment variable relative to the extracted path, e.g.:
# export DVDDIR=/tmp/rhel79 -
Get the kickstart file and rename it to
ks.cfg# cd $DVDDIR # cp /PATH/TO/CREATED/ks.cfg $DVDDIR -
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 quietHere above the label for the DVD is "RHEL-7.9 Server.x86_64" (the space is replaced by "\x20" in the boot entry).
-
Add the new boot entry to
$DVDDIR/isolinux/isolinux.cfgby 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.cfgNote: 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.
-
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 } -
Add the new boot entry to
$DVDDIR/EFI/BOOT/grub.cfgby 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.
-
Finally rebuild the ISO, making sure that
-Voption 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.isoNotes:
-
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
mkisofscommand -
For 64-bit ARM in RHEL9, the
isohybridcommand is not available and it's not required; use the followingmkisofscommand 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
-
Extract the DVD iso to
/newiso: -
Copy the kickstart file ks.cfg in the /newiso/ directory
# cp /path/to/ks.cfg /newiso/ -
Now make
/newiso/isolinux/isolinux.cfgfile writable and make changes in it.# cd /newiso/ # chmod a+w EFI/BOOT/BOOTX64.conf # vi EFI/BOOT/BOOTX64.conf -
Make necessary changes as required, like provide the kickstart file path or any other kernel command line parameters too. One can place the
driverdiskhere as well. E.gtitle Red Hat Enterprise Linux 6.10 Kickstart kernel /images/pxeboot/vmlinuz ks=cdrom:/ks.cfg <additional anaconda boot parameters> initrd /images/pxeboot/initrd.img -
In case one want to make it bootable with Kickstart for
Legacytoo, please make an additional change inisolinux/isolinux.cfgas 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> -
Make the file
EFI/BOOT/BOOTX64.confread only again.# chmod a-w EFI/BOOT/BOOTX64.conf -
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.isowill be created which will be bootable and by default kickstart installation DVD iso. Just hit Enter to install using kickstart fileks.cfgwhich is available into the DVD iso.
- After running the above command, the file
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)
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.