Build a Proxmox Cloud-Init Template + Clone a VM
One script to turn the Ubuntu 24.04 cloud image into a reusable Proxmox template, plus the three commands that clone and personalize a ready-to-boot VM in seconds.
Distrosproxmox
Shell
bashUpdated
Script
# ── Run on the Proxmox host. Placeholders: local-lvm (VM storage),
# ── 9000 (template VMID). Full walkthrough:
# ── /blog/proxmox-cloud-init-template/
# 1. Download the Ubuntu 24.04 LTS cloud image
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img \
-O /var/lib/vz/template/iso/noble-server-cloudimg-amd64.img
# 2. Create the VM shell (serial console — cloud images expect one)
qm create 9000 \
--name ubuntu-2404-template \
--machine q35 --bios ovmf --efidisk0 local-lvm:0,efitype=4m,pre-enrolled-keys=1 \
--ostype l26 \
--cpu host --cores 2 --memory 2048 --balloon 1 \
--scsihw virtio-scsi-single \
--net0 virtio,bridge=vmbr0 \
--serial0 socket --vga serial0 \
--agent enabled=1
# 3. Import the cloud image as the boot disk + add the cloud-init drive
qm set 9000 --scsi0 local-lvm:0,import-from=/var/lib/vz/template/iso/noble-server-cloudimg-amd64.img,discard=on,ssd=1
qm set 9000 --boot order=scsi0
qm set 9000 --ide2 local-lvm:cloudinit
# 4. Freeze it — templates never boot again
qm template 9000
echo "Template 9000 ready. Clone with the commands in the Notes section."
Prerequisites
- Proxmox VE 8.x/9.x host with internet access
- Root shell on the node
- Thin-provisioned VM storage (
local-lvm, ZFS, etc.) for fast clones
Clone and personalize (per new VM)
Substitute the VMID (141), name, key path, and IP for each clone — the
10.0.0.x values below are placeholders:
qm clone 9000 141 --name web01 --full
qm set 141 --ciuser ubuntu --sshkeys ~/.ssh/id_ed25519.pub
qm set 141 --ipconfig0 ip=10.0.0.41/24,gw=10.0.0.1 # or: ip=dhcp
qm resize 141 scsi0 +28G
qm start 141
# one-time per clone: the cloud image does NOT ship the guest agent
ssh ubuntu@10.0.0.41 'sudo apt update && sudo apt install -y qemu-guest-agent'
Notes
- The companion guide explains every flag: Proxmox Cloud-Init Templates
- Cloud images ship ~3.5 GB disks; the
qm resizegrows the clone, and cloud-init expands the filesystem on next boot efitype=4m,pre-enrolled-keys=1matters: with the bare CLI default (legacy 2m EFI vars) our verification VM hung silently before boot on current PVE OVMF — the 4m variant booted cleanly- Ubuntu cloud images do not ship
qemu-guest-agent(verified 2026-07-20) — install it per clone (command above), or bake it into the template once beforeqm templatewithvirt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent(needslibguestfs-tools) - First boot takes 2–3 minutes on modest hardware while cloud-init does its one-time work; later boots are normal speed
- Debian/Fedora/Rocky cloud images work identically — swap the image URL