Customizing the Anaconda Installer Boot Image with product.img
Red Hat’s Anaconda installer, used by Red Hat Enterprise Linux, Oracle Linux, and other RHEL-like distributions, offers a powerful customization method through an additional product.img
file. This technique allows you to modify the first boot sequence with relative ease.
What is product.img?
The product.img
is an additional image file that can be used to override or extend the default installation behavior. It provides a way to inject custom scripts, configuration files, or other resources into the installation process without modifying the original installer. It saves the need to modify Red Hat’s provided install.img (their 2nd stage) and to repackage it, by providing an easy override interface to replace/change/add files to the running Anaconda.
Creating Your Custom product.img
Follow these steps to create a custom product.img
:
- Create a Directory Structure
custom_product/
├── .buildstamp
├── post-install/
│ └── custom-script.sh
├── usr/bin/my-script.sh
- Prepare the .buildstamp File
Create an empty.buildstamp
file in the root directory to mark it as a valid product image. - Add Custom Scripts
Place any custom scripts in thepost-install/
directory for predefined location. These will run after the installation completes. - Add overriding Scripts
Place your my-script.sh (or any of your binaries) in a relative location. If the files already exist on the install.img – your provided files will override them. If not – your files will be added. You can make use of your added commands/script/binaries in the %pre or even in the %post sections of a Kickstart. - Populate the .buildstamp file
The file .buildstamp is required, but can be empty. It is used by Anaconda and its content can validate the product image structure. An example, as provided in Red Hat’s guide, shows contents of the file as follows:[Main]
Product=Red Hat Enterprise Linux
Version=7.4
BugURL=https://bugzilla.redhat.com/
IsFinal=True
UUID=201707110057.x86_64
[Compose]
Lorax=19.6.92-1 - Create the product.img
cd custom_product
find . | cpio -c -o | gzip > ../product.img
Using Your Custom product.img
When booting the installer, add the inst.stage2=
and inst.addrepo=
boot parameters:
inst.stage2=http://your-server/path/to/install/media
inst.addrepo=custom,http://your-server/path/to/product.img
Example Use Cases
- Modify default system configurations
- Add custom post-installation scripts
- Inject additional packages or resources
- Customize initial system setup
Important Considerations
- Ensure compatibility with your specific Linux distribution
- Test thoroughly before deployment
- Keep custom modifications minimal and purposeful
Conclusion
The product.img
method provides a flexible way to customize the Anaconda installer, allowing system administrators to streamline and personalize the installation process with minimal effort.
Additional Info
A quick guide explaining the mechanism exists in Red Hat’s documentation. The guide is for RHEL7, but applies for later versions as well.