I am trying to automate up to date cloud images for Ubuntu and Debian VM templates.
Once a template has been cloned using linked clones, it is not possible to delete the template, so I just change the disk to be used in new clones, while the existing clones can still link to previous disk image.
I can create a template ok, and I can create linked clone ok.
When I later update the cloud image, and change the disk used in the template to the new cloud image, I can no longer clone the template.
Any ideas?
Example script:
Once a template has been cloned using linked clones, it is not possible to delete the template, so I just change the disk to be used in new clones, while the existing clones can still link to previous disk image.
I can create a template ok, and I can create linked clone ok.
When I later update the cloud image, and change the disk used in the template to the new cloud image, I can no longer clone the template.
Any ideas?
Example script:
Bash:
#!/bin/bash
set -e
set -x
# Cleanup
qm destroy 12342 --destroy-unreferenced-disks true || true
qm destroy 12341 --destroy-unreferenced-disks true || true
qm destroy 1234 --destroy-unreferenced-disks true || true
rm -f /data/install/images/test1.qcow2 || true
rm -f /data/install/images/test2.qcow2 || true
# Create a test disk image based on a Debian cloud image
# https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
qemu-img convert -O qcow2 /data/install/images/debian-bookworm-amd64.qcow2 /data/install/images/test1.qcow2
qemu-img resize /data/install/images/test1.qcow2 80G
# Create a new VM template
qm create 1234 \
--name "test-1234" \
--tags "debian,bookworm,cloud-image" \
--memory 8192 \
--balloon 2048 \
--cores 2 \
--net0 "virtio,bridge=vmbr1" \
--scsihw "virtio-scsi-pci" \
--scsi0 "vmdata:0,import-from=/data/install/images/test1.qcow2" \
--boot "order=scsi0" \
--ide2 "vmdata:cloudinit" \
--ciuser "pieter" \
--cipassword "Password1" \
--cicustom "vendor=local:snippets/vendor.yaml" \
--searchdomain "home.insanegenius.net" \
--sshkeys "/home/pieter/.ssh/authorized_keys" \
--ipconfig0 "ip=dhcp" \
--ostype "l26" \
--agent "enabled=1,fstrim_cloned_disks=1"
qm template 1234
# Create a linked clone, ok
qm clone 1234 12341 --name "test-1234-1"
# New cloud image, to be used with new linked clones
qemu-img convert -O qcow2 /data/install/images/debian-bookworm-amd64.qcow2 /data/install/images/test2.qcow2
qemu-img resize /data/install/images/test2.qcow2 80G
# Update the disk used in the template VM to use new cloud image
qm set 1234 --scsi0 "vmdata:0,import-from=/data/install/images/test2.qcow2"
# Create a linked clone, fail
# Linked clone feature is not supported for drive 'scsi0'
qm clone 1234 12342 --name "test-1234-2"
Last edited: