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.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
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.
- Download a cloud image to the node, for example from your distribution’s cloud image site, into a folder such as
/root/images. - 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 - Import the image as the first SCSI disk:
qm set 9000 --scsi0 local-lvm:0,import-from=/root/images/IMAGE.img - Add the cloud-init drive, which passes user and network settings to the guest:
qm set 9000 --ide2 local-lvm:cloudinit - Boot only from the imported disk:
qm set 9000 --boot order=scsi0 - 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. - 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--fullfor an independent copy. --ipconfig0 ip=dhcpuses DHCP instead of a static address.qm disk resizeonly 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 usershows 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 123regenerates 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
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
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 · Explains an idea · 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 · Step by step · 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 · Step by step · 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 · Cheat sheet · 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 · Cheat sheet · 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 · Fixes an error · Linux Article Backup & restore · VMs & containers 15 Oct 2026
Repos in the wild
- proxmox/qemu-server: the Proxmox VE virtual machine manager proxmox/qemu-server Read-only GitHub mirror of qemu-server, the Proxmox VE package that manages QEMU/KVM virtual machines and provides the qm and qmrestore commands. GitHub
- libvirt: virtualization API and daemon (GitHub mirror) libvirt/libvirt libvirt is the toolkit that manages KVM/QEMU and other hypervisors through one API, plus the virsh client. The GitHub repository is a read-only mirror; development happens on GitLab. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +4,209 chars