Most people that know me, know that I don’t usually use Ubuntu for most of my projects, but here it seems it’s best to use Ubuntu or a Debian variant for ease/compatibility sake. I will be using Debian 11. I am using the genericcloud version as it’s best for cloud-init and smaller in size for use with virtualized environments.

At the time of writing this, the image is below. https://cloud.debian.org/images/cloud/bookworm/20230612-1409/debian-12-genericcloud-amd64-20230612-1409.qcow2

So let’s start by creating a base template

qm create 9000 --name debian12-template --memory 2048 --net0 virtio,bridge=vmbr0

next we will import the disk and then attach it to the VM we created above

qm importdisk 9000 /var/lib/vz/template/iso/debian-12-genericcloud-amd64-20230612-1409.qcow2 local -format qcow2

once this disk is created, we can attach the disk

qm set 9000 --scsihw virtio-scsi-pci --scsi0 /var/lib/vz/images/9000/vm-9000-disk-0.qcow2

change settings for the base template

qm set 9000 --ide2 local:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0

increase the disk size to what size you want

qm resize 9000 scsi0 +8G

set dhcp or static IP (both commands are below)

qm set 9000 --ipconfig0 ip=dhcp
#qm set 9000 --ipconfig0 ip=10.10.10.222/24,gw=10.10.10.1

we can set user auth

qm set 9000 --sshkey ~/.ssh/id_rsa.pub
#qm set 9000 --cipassword somepassword

create the template

qm template 9000