Unable to clone VM template after updating disk image

May 22, 2020
16
2
8
53
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:

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:
Hi,
the issue is that the newly added disk to the template is not automatically converted to a base disk. Feel free to open a feature request on the bug tracker (after checking none exists yet): https://bugzilla.proxmox.com/

As a workaround, after adding the new disk, you can create a full clone and then convert that one to a new template.
 
Thank you for the reply.
The workaround is unfortunately no better than creating a new template every time the cloud image is updated, i.e. in-use templates cannot be deleted, and I will end up with a new template for every update, defeating the purpose of keeping one template per cloud image.
Is there no other way of updating the backing disk of an existing template to be used by new instances?
 
Is there no other way of updating the backing disk of an existing template to be used by new instances?
An alternative would be using LVM-thin as a storage, because there you can create linked clones without needing the disk to be a base image. But when the template disk is qcow2, the conversion to base image needs to happen first, which is currently not implemented when adding a new image to a template: https://bugzilla.proxmox.com/
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!