Creating a Custom Rocky Linux ISO
Introduction¶
You might need to create a custom ISO for many reasons. Perhaps you want to change the boot process, add specific packages, or update a configuration file.
This guide will instruct you from start to finish on how to build your own Rocky Linux ISO.
Prerequisites¶
- A 64-bit machine running Rocky Linux 9
- A Rocky Linux 9 DVD ISO image
- A
kickstartfile to apply to the ISO - Read the Lorax Quickstart and mkksiso documentation to become familiar with how to create the
Anacondaboot.iso.
Package installation and setup¶
- Install the
loraxpackage:
sudo dnf install -y lorax
Building the ISO with a kickstart file¶
- Run the
mkksisocommand to add akickstartfile and then build a new ISO:
mkksiso --ks <PATH_TO_KICKSTART_FILE> <PATH_TO_ISO_TO_MODIFY> <OUTPUT_PATH_FOR_BUILT_ISO>
- Below is an example
kickstartfileexample-ks.cfg, which sets up a Rocky Linux 9.5Server With GUIenvironment:
lang en_GB
keyboard --xlayouts='us'
timezone Asia/Tokyo --utc
reboot
cdrom
bootloader --append="rhgb quiet crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
zerombr
clearpart --all --initlabel
autopart
network --bootproto=dhcp
firstboot --disable
selinux --enforcing
firewall --enabled
%packages
@^server-product-environment
%end
Adding a repository with its packages to an ISO image¶
- Make sure the repository you want to add has the
repodatadirectory inside of it. If not, you can create this using thecreaterepo_ccommand and install it withsudo dnf install -y createrepo_c - Add the repository to your
kickstartfile, using the following syntax:
repo --name=extra-repo --baseurl=file:///run/install/repo/<YOUR_REPOSITORY>/
- Add your repository using the
--addflag with themkksisotool:
mkksiso --add <LINK_TO_YOUR_REPOSITORY> --ks <PATH_TO_KICKSTART_FILE> <PATH_TO_ISO_TO_MODIFY> <OUTPUT_PATH_FOR_BUILT_ISO>
- You can see additional details of this process using the
baseosrepository in the example below - The
base osrepository will be locally downloaded along with all of its packages:
dnf reposync -p ~ --download-metadata --repo=baseos
- Then add the repository to the
kickstartfile:
repo --name=extra-repo --baseurl=file:///run/install/repo/baseos/
- The
kickstartfile would look like the following:
lang en_GB
keyboard --xlayouts='us'
timezone Asia/Tokyo --utc
reboot
cdrom
bootloader --append="rhgb quiet crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
zerombr
clearpart --all --initlabel
autopart
network --bootproto=dhcp
firstboot --disable
selinux --enforcing
firewall --enabled
%packages
@^server-product-environment
repo --name=extra-repo --baseurl=file:///run/install/repo/baseos/
%end
- Then point the
mkksisocommand directly to the repository directory and build the ISO:
mkksiso --add ~/baseos --ks example-ks.cfg ~/Rocky-9.5-x86_64-dvd.iso ~/Rocky-9.5-x86_64-dvd-new.iso
Conclusion¶
I'm sharing a few options to tweak and build your Rocky Linux ISO here. For further ways, including modifying the kernel cmdline arguments, the author highly recommends going through the mkksiso documentation in more detail.
Author: Howard Van Der Wal
Contributors: Steven Spencer, Ganna Zhyrnova