Skip to content
Commitpedia
Log in Join & edit

Create a VM and a cloud-init template with qm

Create KVM virtual machines from the command line with qm, then build a reusable cloud-init template from a cloud image and clone ready-to-boot VMs with their own SSH key and IP.

Not checked by a trusted editor yet Last edited Outdated?

Edit history of Create a VM and a cloud-init template with qm: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
3 min

The web UI wizard is the easiest way to create one VM. When you create many, the qm command and a cloud-init template are much faster: you prepare one VM from a distribution’s cloud image, turn it into a template, and clone new VMs that configure their user, SSH key and network on first boot.

Part 1: a VM from an ISO

Upload the installer ISO to a storage that allows ISO images (the default local storage does). Then create the VM. Disk sizes use the syntax STORAGE:SIZE_IN_GiB, which allocates a new volume; memory is in MiB.

qm create 110 --name web01 --ostype l26 \
  --memory 2048 --cores 2 \
  --scsihw virtio-scsi-pci --scsi0 local-lvm:32 \
  --net0 virtio,bridge=vmbr0 \
  --cdrom local:iso/debian-13-netinst.iso \
  --boot 'order=scsi0;ide2'

qm start 110

Open the console in the web UI to run the installer. Useful follow-up commands:

qm config 110          # show the configuration
qm shutdown 110 && qm wait 110
qm set 110 --onboot 1  # start automatically with the host
qm set 110 --agent enabled=1

--agent enabled=1 tells Proxmox VE to talk to the QEMU guest agent. Install the qemu-guest-agent package inside the guest; the setting takes effect after a fresh start of the VM. The agent lets the host shut down the guest cleanly, read its IP addresses and freeze file systems during backups.

Part 2: build a cloud-init template

Many distributions publish cloud images that already contain cloud-init. The following steps follow the official example. Replace the image file with the one you download, and the storage names with your own.

  1. Download a cloud image to the node, for example from your distribution’s cloud image site, into a folder such as /root/images.
  2. Create an empty VM with a VirtIO SCSI controller: qm create 9000 --name tpl-cloud --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
  3. Import the image as the first SCSI disk: qm set 9000 --scsi0 local-lvm:0,import-from=/root/images/IMAGE.img
  4. Add the cloud-init drive, which passes user and network settings to the guest: qm set 9000 --ide2 local-lvm:cloudinit
  5. Boot only from the imported disk: qm set 9000 --boot order=scsi0
  6. Many cloud images expect a serial console: qm set 9000 --serial0 socket --vga serial0. If the image does not show output this way, switch back to the default display.
  7. Convert the VM to a template: qm template 9000
qm create 9000 --name tpl-cloud --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
qm set 9000 --scsi0 local-lvm:0,import-from=/root/images/IMAGE.img
qm set 9000 --ide2 local-lvm:cloudinit
qm set 9000 --boot order=scsi0
qm set 9000 --serial0 socket --vga serial0
qm template 9000

A template cannot be started. It is read-only and serves as the source for clones.

Part 3: deploy VMs from the template

qm clone 9000 123 --name app01
qm set 123 --ciuser admin --sshkeys /root/.ssh/admin.pub
qm set 123 --ipconfig0 ip=192.0.2.123/24,gw=192.0.2.1
qm disk resize 123 scsi0 +18G
qm start 123
  • Without --full, cloning a template creates a linked clone, which shares unchanged data with the template and is created almost instantly. It needs a storage that supports it (for example LVM-thin, ZFS, Ceph or qcow2 files) and depends on the template, so you cannot delete the template while linked clones exist. Add --full for an independent copy.
  • --ipconfig0 ip=dhcp uses DHCP instead of a static address.
  • qm disk resize only grows disks; with + the value is added to the current size. Most cloud images grow their root file system automatically on boot.
  • qm cloudinit dump 123 user shows the generated cloud-init user data, which helps when a setting does not seem to apply. After changing cloud-init options on an existing VM, qm cloudinit update 123 regenerates the drive.

Removing a VM

Warning: qm destroy permanently deletes the VM and all disks it owns. First check that you have the right ID with qm config <vmid> and that a recent backup exists. Add --purge to also remove the VM from backup jobs, replication jobs and HA configuration.

qm config 123 | head
qm destroy 123 --purge

Official documentation

See also

  • 0098 What Proxmox VE is: KVM virtual machines, LXC containers and a web UI Proxmox VE is an open source virtualization platform based on Debian. It runs KVM virtual machines and LXC containers and is managed… Beginner · Concept · Linux Article Basics · Installation & first steps 15 Oct 2026
  • 0101 Create LXC containers with pct and pveam Download a container template with pveam, create an unprivileged LXC container with pct, give it a network address and get a shell… Beginner · How-to · Linux Article VMs & containers 15 Oct 2026
  • 0104 Build a Proxmox VE cluster with pvecm and live-migrate VMs Join Proxmox VE nodes into a cluster with pvecm create and pvecm add, check quorum with pvecm status, then move running VMs… Advanced · How-to · Linux Article Clusters & high availability · VMs & containers 15 Oct 2026
  • 0107 Proxmox VE command line cheat sheet: qm, pct, pvecm, pvesm and more The Proxmox VE commands you use most: qm for VMs, pct for containers, pvesm for storage, pvecm for the cluster, vzdump for… Intermediate · Reference · Linux Article Clusters & high availability · VMs & containers 15 Oct 2026
  • 0108 List all Proxmox VE guests with status and locks (pvesh + jq) A Bash script that lists every VM and container in the cluster with node, status, lock, memory and uptime, using the Proxmox… Intermediate · Reference · Linux Script Shell scripting · VMs & containers 15 Oct 2026
  • 0110 Fix: TASK ERROR: VM is locked (backup) A VM or container still carries a backup lock, usually after a backup was interrupted. Check that no backup is running, then… Beginner · Fix · Linux Article Backup & restore · VMs & containers 15 Oct 2026

Repos in the wild

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Commitpedia +4,209 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?