When learning about linux, one of the best ways to do it is with a home lab. A way of trying new things without worrying about destroying anything important. But this process may become tedious when rebuilding constantly. When using a hypervisor like Proxmox, there are ways to automate the server installation, in this case, for Debian.

What is Proxmox VE

Proxmox is a platform for virtualization. Maybe you have tried things like VirtualBox or VMWare, well, it is something like that but focused on a web interface where you can manage VMs and linux containers. It helps with the administration of networking, HA and quality of lives things like Cloud Init.

What is Cloud Init

Cloud init is a method of provisioning systems for cloud or bare metal, it is like a instance setup script that help with the basics.

How to configure the template

Download the image

THe base image is needed. You should search for the .qcow2 file. You can obtain it from https://cloud.debian.org/images/cloud/.

There you should search for the generic cloud image, the image can be downloaded directly from the web interface.

Create the Proxmox VM template

The commands create a VM with basic resources and networking, importing the image to the Proxmox local storage. The cloud init activation is also done.

qm create 999 --name DebianCloudInit --net0 virtio,bridge=vmbr0
qm importdisk 999 debian-XX-genericcloud-amd64-XXXX.qcow2 local-lvm
qm set 999 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-999-disk-0
qm set 999 --ide1 local-lvm:cloudinit
qm set 999 --boot c --bootdisk scsi0
qm set 999 --serial0 socket --vga serial0
qm set 999 --agent enabled=1
qm template 999

Use the template

From the web interface you can clone the VM, with the clone you can interact with the Cloud Init tab where you can automate the VM installation

Last steps

You may setup the virtualization agent to be able to power the VM off from the Proxmox interface.

sudo apt update
sudo apt full-upgrade
sudo apt install qemu-guest-agent