2025-10-07 23:16:15 +02:00
# Proxmox cloud-init guide with Debian Trixie as example
2025-10-07 23:11:08 +02:00
source: [https://forum.proxmox.com/threads/pve9-create-a-vm-template-for-a-debian-trixie-server-with-cloud-init.170206 ](https://forum.proxmox.com/threads/pve9-create-a-vm-template-for-a-debian-trixie-server-with-cloud-init.170206 )
2025-10-08 21:45:36 +02:00
### Tools man-pages
2025-10-07 23:11:08 +02:00
2025-10-08 21:45:36 +02:00
* virt-customize: [https://manpages.debian.org/trixie/guestfs-tools/virt-customize.1.en.html ](https://manpages.debian.org/trixie/guestfs-tools/virt-customize.1.en.html )
2025-10-08 21:49:04 +02:00
* qemu-img: [https://manpages.debian.org/trixie/qemu-utils/qemu-img.1.en.html ](https://manpages.debian.org/trixie/qemu-utils/qemu-img.1.en.html )
2025-10-08 21:45:36 +02:00
Install mandatory tools for image customization:
```
apt install libguestfs-tools
2025-10-07 23:11:08 +02:00
```
2025-10-08 21:45:36 +02:00
Download the latest cloudinit-image for Trixie:
2025-10-07 23:11:08 +02:00
2025-10-08 21:45:36 +02:00
```
wget https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2
```
2025-10-07 23:11:08 +02:00
2025-10-08 21:49:04 +02:00
Verify cheksum against: [https://cloud.debian.org/images/cloud/trixie/latest/SHA512SUMS ](https://cloud.debian.org/images/cloud/trixie/latest/SHA512SUMS )
2025-10-07 23:11:08 +02:00
2025-10-08 21:45:36 +02:00
```
sha512sum debian-13-genericcloud-amd64.qcow2 #check against https://cloud.debian.org/images/cloud/trixie/latest/SHA512SUMS
```
2025-10-07 23:11:08 +02:00
2025-10-08 21:45:36 +02:00
customize the image:
```
2025-10-07 23:11:08 +02:00
virt-customize -a debian-13-genericcloud-amd64.qcow2 --install qemu-guest-agent,curl,wget,nano,rsync,htop,tmux #tools I like to add
virt-customize -a debian-13-genericcloud-amd64.qcow2 --run-command "sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config" #to enable root login which is off by default
virt-customize -a debian-13-genericcloud-amd64.qcow2 --run-command "sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config" #to enable SSH authentication by password - my use choice
qemu-img convert -O qcow2 -c -o preallocation=off debian-13-genericcloud-amd64.qcow2 debian-13-genericcloud-amd64-shrink.qcow2 #convert & compress qcow2 image
2025-10-08 21:45:36 +02:00
```
2025-10-07 23:11:08 +02:00
#send image to PVE host:
2025-10-08 21:45:36 +02:00
```
2025-10-07 23:11:08 +02:00
scp debian-13-genericcloud-amd64-shrink.qcow2 root@........................... #enter desired location on host node
```
In PVE host:
2025-10-07 23:16:15 +02:00
* Create a VM 200 # use {vmid} you wish
* Name: Debian-Trixie-CloudINIT-Template #name I used
* Do not use any media, Qemu Agent (ticked), Remove all disk, 2 cores x86-64-v2-AES, 4096 RAM #settings I chose
* Set to not run on completion
2025-10-07 23:11:08 +02:00
In Host node shell:
2025-10-07 23:13:08 +02:00
```
2025-10-07 23:11:08 +02:00
qm importdisk 200 debian-13-genericcloud-amd64-shrink.qcow2 Storage --format qcow2 #change 200 to the actual {vmid} you used above & required Storage location, I used 'Storage'
2025-10-07 23:13:08 +02:00
```
2025-10-07 23:11:08 +02:00
In GUI of VM 200 (or your {vmid} as above):
2025-10-07 23:13:08 +02:00
* Remove the CD/DVD drive # I don't need one
* Add unused disk as scsi0, ssd on discard on default nocache #my choices, adjust accordingly
* Add cloud-init drive as ide0
* In cloud-init set User as root & password, set IPV4 as dhcp #my choices, adjust accordingly
* In VM Options set boot order scsi0 as first & only boot device
* Convert VM 200 (or your {vmid} as above) to Template
2025-10-07 23:11:08 +02:00
Done! #I make a backup of this VM template once done.
Testing:
2025-10-07 23:13:08 +02:00
* Create a Full clone
* Set Cloud-Init settings of the clone as required & regenerate Cloud-Init image
* Start cloned VM (This will fully setup the VM & should fully Update & Upgrade it)
* Shutdown
* In GUI; Remove Cloud-Init drive from Hardware
2025-10-07 23:11:08 +02:00
Done!