Installing Linux from an ISO every time is slow. A Proxmox cloud-init template lets you clone a ready image and set the hostname, user, SSH key and IP at first boot, so a new VM is ready in under a minute. This is the same approach VPS providers use for fast provisioning.
Before you start
- A working Proxmox VE host; see install Proxmox VE.
- Shell access to the node (node → Shell or SSH).
- A storage for VM disks, such as
local-lvmor a ZFS pool. - Pick an unused VM ID for the template, e.g. 9000.
Download a cloud image
cd /var/lib/vz/template/iso && wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.imgDebian publishes equivalent genericcloud qcow2 images.
Create the template VM
qm create 9000 --name ubuntu-2404-tpl --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-singleqm importdisk 9000 noble-server-cloudimg-amd64.img local-lvmqm set 9000 --scsi0 local-lvm:vm-9000-disk-0,discard=on --boot order=scsi0qm set 9000 --ide2 local-lvm:cloudinit --serial0 socket --vga serial0 --agent enabled=1On newer Proxmox releases qm disk import is the preferred spelling of importdisk. Adjust the storage name to yours.
Set cloud-init defaults
In the GUI open VM 9000 → Cloud-Init and set user, password or SSH public key, DNS and IP Config (DHCP or static). Or from the shell:
qm set 9000 --ciuser admin --sshkeys /root/admin.pub --ipconfig0 ip=dhcpThen convert it:
qm template 9000Deploy a VM from the template
qm clone 9000 120 --name web01 --fullqm set 120 --ipconfig0 ip=203.0.113.20/24,gw=203.0.113.1 --nameserver 1.1.1.1qm resize 120 scsi0 +30Gqm start 120Cloud images grow their root partition automatically on first boot. Log in with your key: ssh admin@203.0.113.20.
After first boot
- Install
qemu-guest-agentin the template image (or each clone) so Proxmox shows IPs and shuts down cleanly. - Harden SSH; see SSH lockdown checklist.
Troubleshooting
- VM does not get settings: the cloud-init drive is missing; re-add
ide2as cloudinit and click Regenerate Image. - Stuck at boot with no console: the serial console must be enabled as above.
- Disk did not grow: confirm the resize, then reboot;
growpartruns at boot.
Frequently asked questions
Full or linked clone?
Full clones are independent copies. Linked clones save space but depend on the template.
Does this work with Windows?
Windows uses cloudbase-init instead and needs a sysprepped image.
Can I add custom cloud-init config?
Yes, put a snippet file on a storage with snippets content and use --cicustom.
