Skip to content

Instantly share code, notes, and snippets.

@maurerle
Last active October 7, 2025 21:39
Show Gist options
  • Select an option

  • Save maurerle/dec405f764a815431dc245aa14e12648 to your computer and use it in GitHub Desktop.

Select an option

Save maurerle/dec405f764a815431dc245aa14e12648 to your computer and use it in GitHub Desktop.
Script to create a cloud-init debian VM template for Proxmox from a debian cloud image
#!/bin/bash
# makes a cloud-init template vm from URL
# call like ./make-debian-template.sh 9000
# Check for root priviliges
if [[ $EUID -ne 0 ]]; then
printf "Please run as root:\nsudo %s\n" "${0}"
exit 1
fi
ID=$1
URL=${2:-"https://cloud.debian.org/images/cloud/trixie/latest/debian-13-genericcloud-amd64.qcow2"}
FS=lvm
# decide between lvm, zfs or btrfs
wget $URL -O cloud-init.qcow2
qm create $ID --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci --memory 2048 --cores 4 --machine q35
command -v virt-customize
# install libguestfs-tools to have virt-customize
if [[ $? -eq 0 ]]; then
echo "installing qemu-guest-agent into guest"
virt-customize -a cloud-init.qcow2 --install qemu-guest-agent
qm set $ID --agent 1
else
echo "will not install qemu-guest-agent into guest"
fi
qm importdisk $ID ./cloud-init.qcow2 local-$FS
[ "$FS" == "btrfs" ] && qm set $ID --scsi0 local-$FS:$ID/vm-$ID-disk-0.raw
[ "$FS" == "lvm" ] && qm set $ID --scsi0 local-$FS:vm-$ID-disk-0
[ "$FS" == "zfs" ] && qm set $ID --scsi0 local-$FS:vm-$ID-disk-0
qm set $ID --scsi1 local-$FS:cloudinit
qm set $ID --serial0 socket --vga serial0
qm set $ID --name cloud-init-template
qm set $ID --boot order=scsi0
qm template $ID
@umatrix81
Copy link

virt-customize doesn't work with latest proxmox version, guest doesn't get internet access.

@maurerle
Copy link
Author

maurerle commented Oct 7, 2025

sudo apt install dhcpd-base
See Post in thread 'Proxmox 9 upgrade: Virt-customize no longer has internet access'
https://forum.proxmox.com/threads/proxmox-9-upgrade-virt-customize-no-longer-has-internet-access.169355/post-797808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment