Usage
Parameters
Path of the base Azure Linux image which the customization will be applied to
Path to write the customized image to
Path of the image customization config file (YAML format)
Directory to run build out of
Format of output image. Supported: vhd, vhd-fixed, vhdx, qcow2, raw, iso
Format of partition files. Supported: raw, raw-zst
Path to a RPM repo config file or a directory containing RPMs (can be specified multiple times)
Disable the base image’s RPM repos as an RPM source
Enable shrinking of filesystems to minimum size. Supports ext2, ext3, ext4 filesystem types. Requires
--output-split-partitions-format.Create a directory with customized image PXE booting artifacts.
--output-image-format must be set to iso.File that stores timestamps for this program
Path to the log file
Log level (panic, fatal, error, warn, info, debug, trace)
How It Works
- Mount Image: Attaches the base image as a loopback device and mounts its filesystems
- Apply Customizations: Installs packages, modifies configurations, adds users, etc.
- Run Scripts: Executes custom scripts in chroot environment if specified
- Create Output: Generates the customized image in the specified format
- Optional Processing: Shrinks filesystems or creates PXE artifacts if requested
Customization Options
The YAML configuration file supports:OS Customizations
- Package Management: Install, remove, or update packages
- Users and Groups: Create users, set passwords, configure SSH keys
- Network: Configure hostname, network interfaces, DNS
- Services: Enable or disable systemd services
- Files: Add or modify files
- Scripts: Run custom scripts during customization
Storage Customizations
- Partitions: Modify partition layout
- Filesystems: Resize or modify filesystems
- Verity: Configure dm-verity for read-only partitions
Example Usage
Basic Package Installation
Advanced Customization
ISO with PXE Artifacts
Split Partitions with Shrinking
Advantages of Chroot Approach
- Lower Overhead: No need to boot and shutdown the OS
- Precision: Direct file system modifications without running OS side effects
- Fewer Requirements: SSH and other services don’t need to be pre-installed
- Faster: No boot time or VM overhead
Limitations
- Some tools don’t work properly in chroot (e.g., systemd operations, some network tools)
- Cannot test runtime behavior during customization
- Limited ability to initialize complex services (e.g., Kubernetes cluster initialization)
Notes
- Requires root privileges for loopback device and chroot operations
- Either
--output-image-formator--output-split-partitions-formatmust be specified - The
--shrink-filesystemsflag is useful for creating minimal images but requires--output-split-partitions-format - Use
--disable-base-image-rpm-reposwhen you want to use only specific RPM sources - Configuration file format is YAML, unlike imagegen which uses JSON
See Also
- Image Customizer Configuration Documentation
- Imagegen - For building images from scratch