Templates
Templates are the blueprint VMs are created from: they define the virtual hardware (firmware type, devices, memory defaultsβ¦) and, optionally, pre-installed disk content.
π Two kinds of templatesβ
- Built-in templates: shipped with XCP-ng, one per supported guest OS family. They contain no disk content: they only carry the right virtual hardware settings and optimizations for that OS (device model, boot mode, memory defaultsβ¦). You install the OS yourself from an ISO or network. Always create a VM from the template matching its OS: this is what guarantees the best defaults.
- Custom templates: created by you from an existing VM or snapshot. They include the disks' content, so new VMs start as exact copies. This is the classic "golden image" workflow.
List available templates:
# xe template-list params=name-label
If built-in templates are missing (e.g. after an incomplete upgrade), see this troubleshooting entry.
πΈ Create a custom templateβ
From a VMβ
Halt the VM, then in Xen Orchestra use Convert to template (VM advanced tab). With xe, converting is a one-way flag flip:
# xe vm-param-set uuid=<vm-uuid> is-a-template=true
If you want to keep the original VM, clone it first and convert the clone.
From a snapshotβ
A snapshot of a running VM can become a template without ever stopping the source VM: in Xen Orchestra, snapshot list β create template from snapshot, or:
# xe snapshot-export-to-template snapshot-uuid=<snapshot-uuid> filename=my-template.xva # xe vm-import filename=my-template.xva preserve=true
π§Ό Prepare the source before templatingβ
New VMs created from a custom template are clones: anything unique to the source machine gets duplicated. Before converting a source VM into a template:
- Linux: clear
/etc/machine-id, remove SSH host keys (they'll regenerate at boot with most distros), remove static network configuration, clean logs and package caches. Even better, installcloud-initso each new VM configures its hostname, users and network at first boot. Xen Orchestra has first-class cloud-init support (see cloud features). - Windows: run
sysprep /generalizeso each clone gets its own machine identity.
A full worked example (cloud image β prepared VM β template β new VMs) is in the Ubuntu custom templates guide.
π Create VMs from a templateβ
From Xen Orchestra: New β VM and pick your template: custom templates appear alongside built-in ones. With xe:
# xe vm-install template="my-golden-image" new-name-label="new-vm" sr-uuid=<sr-uuid>
For repeated or automated deployments, drive this with Terraform/OpenTofu, Packer or Ansible.
π¦ Move templates aroundβ
Templates export and import like VMs, in XVA format, which is handy to copy a golden image to another pool:
# xe template-export template-uuid=<template-uuid> filename=my-template.xva # xe vm-import filename=my-template.xva preserve=true
Or from Xen Orchestra, export/import from the template's view (see import and export).
ποΈ Delete a custom templateβ
In Xen Orchestra, from the templates list (Home β VMs β templates filter). With xe:
# xe template-uninstall template-uuid=<template-uuid>
This also removes the template's disks (after confirmation).