Use this when maintaining the approved master image for a role.
Golden Image
A golden image is the approved, patched and hardened master OS image that all VMs for a role are built from. Version it, rebuild it regularly, and avoid manual changes to deployed copies so they stay consistent.
1. A golden image is the approved, hardened base OS image.
2. Build automatically (Packer).
3. Include patches, agents, hardening.
4. Version and checksum it.
5. Retire old versions.
build pipeline → golden image → templates → VMs
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
- Version recorded and built from code (Packer) where possible.
- Patched and scanned before publishing.
- Hardening baseline applied (CIS).
- Old versions retired on a schedule.
Step 2 Common mistakes Narrow the fault
- One golden image for every role, causing bloat.
- Images patched by hand and not reproducible.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Version every image build.
- Test an image before publishing it.
virt-sysprep -a image.qcow2— clean image identifierssha256sum golden-<ver>.qcow2— image checksumGet-WindowsImage -ImagePath install.wim— Windows image info
ReferenceWhy it matters1 section · depth on demand
How it works
A golden image is the approved, hardened base image for an OS or role, rebuilt regularly (often with Packer) and published as templates or cloud images.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
A repeatable golden-image pipeline
1. Build from vendor media or a cloud image with an automated installer (Packer, kickstart/preseed, autounattend.xml) — never by hand.
2. Patch to the current level and install the baseline: guest agent, monitoring/EDR agent, VirtIO drivers, security baseline.
3. Harden — disable unused services, set logging, apply CIS-style settings that suit all workloads.
4. Generalise — remove identity: virt-sysprep for Linux images (offline), sysprep /generalize /oobe /shutdown for Windows.
5. Compact — virt-sparsify --in-place image.qcow2 to drop freed blocks.
6. Test — boot a throwaway instance, run smoke tests (network, agent, time sync, package repositories).
7. Publish as a versioned template; record the build log and package list.
What virt-sysprep removes
The virt-sysprep manual lists operations that strip clone-unsafe state, for example:
| Operation | Removes |
|---|---|
machine-id | Local machine ID set at install |
ssh-hostkeys | SSH host keys (regenerated on next boot) |
logfiles | System and service logs |
net-hwaddr | Hard-coded MAC addresses in network configuration |
$ virt-sysprep -a golden-debian12.qcow2 --operations defaults,-ssh-userdir
$ virt-sysprep --list-operations | grep '\*' # default operations
Run it only on a powered-off image; running it against a live guest corrupts the file system.
Golden image vs. configuration management
Keep the image small and generic; put workload-specific configuration in cloud-init, Ansible or similar. An image that contains application configuration needs a rebuild for every config change and drifts quickly.
Rebuild cadence
Monthly (after patch day) is a common rhythm; rebuild immediately for critical vulnerabilities in base packages. Old images should be retired, not patched in place — patching a template turns it back into a snowflake.
*The golden-image preparation commands above are illustrative examples, not captured from a lab or production host.*
Reference
| Practice | Why |
|---|---|
| Build with Packer from code | Reproducible |
| Monthly rebuild | Patched baseline |
| Scan before publishing | No known vulnerabilities shipped |
| Semantic version in name | Traceable deployments |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in VM Templates → Golden Image. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/docs.html · confidence 94%