Last active
November 18, 2025 05:42
-
-
Save alatalo/af0b91d752f23ea8b705a112519582f6 to your computer and use it in GitHub Desktop.
Proxmox VE shell commands to create Debian 13 cloud-init ready VM template and deploy a VM from the template with cloud-init settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Proxmox VE shell commands to create Debian 13 cloud-init ready VM template and | |
| # deploy a VM from the template with cloud-init settings | |
| # | |
| # Tested on Proxmox VE 8.4.14 and 9.0.11 | |
| # Run the commands on the Proxmox VE host as root | |
| # Note: This is not a shell script ready to be run, it's just a list of commands | |
| # | |
| # https://github.com/alatalo | |
| # | |
| # create working directory | |
| mkdir -p /root/debian-cloudinit | |
| cd /root/debian-cloudinit | |
| # install required tooling | |
| apt install libguestfs-tools -y | |
| # get the debian 13 generic cloud image from https://cloud.debian.org/images/cloud/ | |
| wget https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2 | |
| # or alternatively, get the generic image | |
| #wget https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2 | |
| # make a copy of the image for keepsake purposes | |
| mkdir -p ./iso | |
| cp debian-13-genericcloud-amd64.qcow2 ./iso | |
| # pre-install selected packages | |
| virt-customize -a debian-13-genericcloud-amd64.qcow2 --install qemu-guest-agent,nano,htop,tmux,curl,wget | |
| # reset machine id to avoid duplicates in clones | |
| virt-customize -a debian-13-genericcloud-amd64.qcow2 --truncate /etc/machine-id | |
| # shrink the image to save space | |
| qemu-img convert -O qcow2 -c -o preallocation=off debian-13-genericcloud-amd64.qcow2 debian-13-genericcloud-amd64-shrink.qcow2 | |
| # get image infos to see the difference | |
| qemu-img info debian-13-genericcloud-amd64.qcow2 | |
| qemu-img info debian-13-genericcloud-amd64-shrink.qcow2 | |
| # --------------------------------- | |
| # create a vm template | |
| # | |
| # here we create a template vmid 9100 named Debian13-cloudinit-ready with | |
| # 1 cpu core, 1GB memory and Start at boot + Qemu guest agent enabled | |
| # | |
| # replace 9100 with your desired template vmid | |
| # replace "local-lvm" with your storage name (local-lvm, local-zfs, nfs-storage, etc) | |
| # --------------------------------- | |
| qm create 9100 --name "Debian13-cloudinit-template" --cores 1 --memory 1024 --net0 virtio,bridge=vmbr0 | |
| qm importdisk 9100 debian-13-genericcloud-amd64-shrink.qcow2 local-lvm | |
| qm set 9100 --description "Debian 13 cloud-init ready template" | |
| qm set 9100 --ostype l26 | |
| qm set 9100 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9100-disk-0,ssd=1 | |
| qm set 9100 --boot c --bootdisk scsi0 | |
| qm set 9100 --ide2 local-lvm:cloudinit | |
| qm set 9100 --agent enabled=1 | |
| qm set 9100 --onboot 1 | |
| qm template 9100 | |
| # --------------------------------- | |
| # deploy a vm using the template | |
| # | |
| # here we create vmid 601 named deb13-foo, with 8GB extra disk, | |
| # dhcp ip, cloud-init user + password and ssh key | |
| # | |
| # you can also create vm from the gui using the template (clone > full) and configure | |
| # cloud-init options there | |
| # --------------------------------- | |
| qm clone 9100 601 --name deb13-foo --full | |
| qm resize 601 scsi0 +8G | |
| qm set 601 --ipconfig0 ip=dhcp | |
| #qm set 601 --ciuser pveadmin --cipassword hunter2 | |
| # if you omit user/pass, then user: debian, sshkey: | |
| qm set 601 --sshkey <(echo "ssh-ed25519 AAAAf00b4r") | |
| qm start 601 | |
| # adjust memory and cpu | |
| #qm set 601 --memory 4096 --cores 4 | |
| # use static ip assignment | |
| #qm set 601 --ipconfig0 ip=10.0.10.58/24,gw=10.0.10.1 | |
| # use tagged vlan 40 nic | |
| #qm set 601 -net0 "virtio,bridge=vmbr0,tag=40" | |
| # use serial console | |
| #qm set 601 --serial0 socket --vga serial0 | |
| # add vm to high availability (ha) cluster | |
| ha-manager add 601 --max_restart 1 --max_relocate 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment