Lets setup a Debian 12 cloud image in proxmox and make it easier to bring up Debian 12 instances.

I had the Debian 11 version here and decided to create a new version rather than update that one. Plus, I want to make a script for this and I will include that in here too. Remember, cloud images are a quick way to configure ProxMox to utilize a new instance. This also works for Ubuntu; so, I will add that in the future here too. For now, lets get the basics down.

One more thing to do to proxmox or where ever you want to download the image

apt install libguestfs-tools -y

That was a neat trick I saw on Create ProxMox Ubuntu Image that I integrated into my process.

The new version expects the following things in environment variables

  • SOME_PASSWORD – Used for user login
  • ST_VOL – c-vm in my case, but where do you want the image to be stored in proxmox aka local-lvm???
  • PUB_SSHKEY – the public ssh key path that will be used by ssh to allow access to vm
  • VM_ID – here I am using 9120
cd ~
qm destroy $VM_ID
rm debian-12*.qcow2
# Get the latest image from debian...
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2 -O debian-12-generic-amd64.qcow2
# Currently this is causing problems with system id and system does not work well once this is ran 
# blacklist with /etc/apt/apt.conf.d/50unattended-upgrades
#linux-headers
#inux-image
#linux-generic
#linux-modules

virt-customize -a debian-12-generic-amd64.qcow2 \
 --install qemu-guest-agent \
--truncate /etc/machine-id \
--append-line '/etc/sysctl.d/99-k8s-cni.conf:'\
--append-line '/etc/sysctl.d/99-k8s-cni.conf:net.bridge.bridge-nf-call-iptables=1'\ 
--append-line '/etc/sysctl.d/99-k8s-cni.conf:net.bridge.bridge-nf-call-ip6tables=1'\
--timezone "America/Chicago"


# create vm called debian12-cloud with 2048 memory and net0 at vmbr0
qm create $VM_ID --name debian12-cloud --cpu host --machine q35 --memory 2048 --cores 4 --numa 1 --net0 virtio,bridge=vmbr0 --agent enabled=1,fstrim_cloned_disks=1,type=virtio

# now make into a proxmox compatible image file.
qm importdisk $VM_ID debian-12-generic-amd64.qcow2 $ST_VOL -format qcow2

# now attach it to scsi interface as a disk
qm set $VM_ID --scsihw virtio-scsi-pci --scsi0 $ST_VOL:vm-$VM_ID-disk-0

# create the boot image disk
qm set $VM_ID --ide2 $ST_VOL:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0 

#Oh, resize the disk from 2G to 30G 
qm resize $VM_ID scsi0 +28G

# set dhcp or static
qm set $VM_ID --ipconfig0 ip=dhcp
##qm set 9120 --ipconfig0 ip=10.10.10.222/24,gw=10.10.10.1

# Copy over the public ssh key
qm set $VM_ID --sshkey $PUB_SSHKEY

# Set Debian password
qm set $VM_ID --cipassword $SOME_PASSWORD
#qm set <vmid> --cicustom "user=local:snippets/user-data.yml"

# done now dump the user
qm cloudinit dump $VM_ID user

qm template $VM_ID

#remove downloaded image. NOTE: Below will remove ALL debian-11 with extension qcow2!!! You have been warned!!! 
rm debian-12*.qcow2

End result of this script is this

Now, do not run it but just make it a template

How To Convert To Template in ProxMox

Once all of this is done it is ready for use in proxmox. Good luck and enjoy to experience proxmox has to offer. Overall, I find it one of the most capable hypervisors for home and as far as I am concerned enterprise vm’s.

Leave a Reply

Your email address will not be published. Required fields are marked *