Skip to content
Mementropy
RecipesHomelab recipesReference

Building an Ubuntu cloud-init template on Proxmox

A template with the guest agent baked in and predictable first boots.

By Ryan Hammang

A Proxmox template whose clones report their address, shut down cleanly and freeze filesystems for backups.

  • Proxmox VE 9
  • libguestfs-tools on the Proxmox host
  1. Download the Ubuntu cloud image and check its SHA-256. Work on a copy:
Terminal window
cp resolute-server-cloudimg-amd64.img work.img
  1. Bake in the guest agent, update packages, and clear the machine ID:
Terminal window
virt-customize -a work.img \
--update \
--install qemu-guest-agent \
--run-command "systemctl enable qemu-guest-agent" \
--truncate /etc/machine-id
  1. Create the VM, import the disk, add a cloud-init drive, set --agent enabled=1, and convert it to a template (ID 9000 or similar).
  2. For quick throwaway clones, add --ciupgrade 0 so first boot doesn’t upgrade packages.
  • qm agent <id> ping succeeds a few seconds after a clone starts.
  • SSH answers right away on clones with ciupgrade 0.
  • Stock Ubuntu cloud images don’t include qemu-guest-agent. Enabling the agent in Proxmox only adds the host side.
  • ciupgrade: 1 (the default) upgraded openssh-server on first boot, and SSH refused connections for about 15 seconds.
  • cloud-init status --long can say degraded done because of a deprecation warning about the user key that Proxmox writes. errors: [] means it’s fine.
  • Use qm guest exec to look inside a VM when SSH isn’t up.