Rolling my own AlmaLinux 9 Live ISO
Introduction
For me there are mostly two reasons to build my custom AlmaLinux / RockyLinux / CentOS Live ISO:
- Having a specialized ISO with maintenance tools, in case your computer stops booting.
- Implementing a specialized installer ISO that extends functionality of the default installer.
And since I also need it for my thesis, I thought of rolling a simple Live ISO for a custom Enterprise Linux Image.
How installation works for RHEL-based systems
When you are install CentOS or any of it’s derivates,
you basically start a Live Image from a CD or a thumb drive (boot.iso
).
This Live Image contains a piece of software called anaconda
.
anaconda
is a graphical tool and also a command line tool,
which does the installation for you and is also very versatile.
All of this is done by creating a Kickstart template, which is in essance a text description of the system you want to build.
In mass deployments these images can also be used for things like PXE booting.
The parser and generator for these kickstart files is called pykickstart.
Prerequisites
For this short tutorial, I will be using AlmaLinux 9.4, but of course this would also work with Rocky Linux / CentOS / etc.
An important prerequisite is that the build host has virtualization enabled.
If the build host is running in a VM as well, you need to have nested virtualization enabled.
Installing all the tools
First of all, we need to install the lorax
package which includes livemedia-creator
.
To actually create the images inside of a vm, we need to install qemu-kvm
.
Additionally we want to run ksvalidator
which is part of pykickstart
.
sudo yum install lorax qemu-kvm pykickstart
Kickstart files
Linux Flavour | Link to Kickstart |
---|---|
AlmaLinux 8, 9 | https://github.com/AlmaLinux/sig-livemedia |
CentOS Stream 8, 9 | https://gitlab.com/redhat/centos-stream/release-engineering/kickstarts |
Fedora | https://pagure.io/fedora-kickstarts/tree/main |
Rocky Linux 8, 9 | https://github.com/rocky-linux/kickstarts |
Rolling the first release
First of all we need a boot iso we can base our custom image off:
wget http://mirror.alwyzon.net/almalinux/9.4/isos/x86_64/AlmaLinux-9.4-x86_64-boot.iso
When calling livemedia-creator
a lot of things happen under the hood.
Since we want the build pipeline to fail-fast, we can start by calling ksvalidator
to validate the kickstart file before starting the build process.
ksvalidator lukas.ks && echo "OK" || echo "ERROR"
Finally, we can start building…
livemedia-creator --make-iso \
--iso AlmaLinux-9.4-x86_64-boot.iso \
--ks lukas.ks \
--nomacboot \
--resultdir /root/isobuild/result_iso \
--project LukasOS \
--releasever 2024.1 \
--iso-only \
--iso-name my_live_image.iso
Result
[root@localhost isobuild]# ls -al result_iso
total 1122768
drwxr-xr-x. 2 root root 35 Sep 30 01:22 .
drwxr-xr-x. 4 root root 178 Sep 30 01:26 ..
-rw-r--r--. 1 root root 1149714432 Sep 30 01:22 my_live_image.iso