Image with Packer¶
MAAS Custom Images
By default, MAAS only includes an image for Ubuntu. If you want to add an image for another operating system, you need to build it in the appropriate format using the Packer application.
🎯 Goal¶
To build a clean debian-custom-cloudimg.tar.gz image for MAAS deployment.
🛠️ Environment & Tools¶
Host Environment:
- Windows 11 / WSL2 (Ubuntu)
- Builder: Packer with QEMU builder
Repository:
Clone Canonical's MAAS Image Builder (based on HCL format):
1. Packer Configuration (WSL2/QEMU)¶
The default configuration required modifications primarily due to the Nested Virtualization environment (QEMU running inside WSL2/Hyper-V).
1.1. KVM Acceleration Fix (Crucial for WSL2)¶
The main build may fail because QEMU attempts to use KVM acceleration (accel=kvm), which is inaccessible from within WSL2, resulting in a "Permission denied" error.
File Modified: debian-cloudimg.pkr.hcl
Original configuration:
# Original (doesn't work in WSL2)
qemu_machine = { "amd64" = "accel=kvm" }
qemu_cpu = { "amd64" = "host" }
Fixed configuration for WSL2 emulation:
locals {
qemu_machine = { "amd64" = "q35" } # Use standard machine without KVM flag
qemu_cpu = { "amd64" = "max" } # Use safe CPU setting
}
Explanation:
- Removed hardcoded KVM flags in the
localsblock - Forces pure software emulation (slower but works in WSL2)
- Uses
q35machine type (standard x86_64 chipset) - Uses
maxCPU model (safe fallback without host-passthrough)
1.2. Boot Mode Configuration¶
Switched the boot mode to BIOS (BOOT=bios) to avoid potential conflicts with UEFI/OVMF firmware copying and usage within the QEMU environment.
1.3. Build the Image¶
Run the build command:
Build process:
- Packer downloads the Debian Trixie ISO
- QEMU starts the VM in software emulation mode
- Automated installation proceeds via preseed
- Image is packaged as
debian-custom-cloudimg.tar.gz
Expected output:
==> Builds finished. The artifacts of successful builds are:
--> qemu.debian: debian-custom-cloudimg.tar.gz
2. MAAS Deployment Steps¶
After a successful build, the image is ready for deployment.
2.1. File Transfer¶
Copy the image to the MAAS server:
2.2. Upload Image to MAAS¶
SSH to the MAAS server and upload the custom image:
ssh user@maas_server_ip
# Upload the custom image
maas admin boot-resources create \
name='custom/debian-trixie' \
title='Debian 13 Trixie Custom' \
architecture='amd64/generic' \
filetype='tgz' \
content@=debian-custom-cloudimg.tar.gz
2.3. Verify Image Upload¶
Check if the image was uploaded successfully:
Look for your custom image in the list:
2.4. Deploy to Nodes¶
Via MAAS UI:
- Navigate to Machines
- Select a node in Ready state
- Click Deploy
- Choose custom/debian-trixie from the OS dropdown
- Confirm deployment
Via CLI:
🐛 Troubleshooting¶
Build Fails with "Permission denied" (KVM)¶
Symptom:
Solution:
Apply the KVM fix in section 1.1 - force software emulation by removing accel=kvm.
Build is Very Slow¶
Cause:
Software emulation (no KVM) is significantly slower than hardware acceleration.
Expected time:
- With KVM: 5-10 minutes
- Without KVM (WSL2): 30-60 minutes
Solution:
Be patient. Consider building on native Linux with KVM support for faster builds.
OVMF/UEFI Boot Issues¶
Symptom:
Solution:
Use BOOT=bios flag as shown in section 1.2.