Questions about virtual disks lifecycle under Proxmox

Dr-Shadow

Member
Dec 29, 2021
9
0
6
33
Hello from France,

I'm asking for some guidance/better explanations about something I'm trying to do with some Virtual Machines under Proxmox VE.
I'm using IaC tools (Terraform / Terragrunt).
My idea is to create a virtual disk statically and attach it to a virtual machine I would build again and rebuild when needed (configuration is provided through cloud-init which is currently working perfectly fine).

This idea would allow to persist the data (so the virtual disk would be a data disk used by the virtual machine).
I saw that virtual disk creation is allowed by the API here : Proxmox API and it's management (e.g attaching) here : Proxmox API

About the API call which allows virtual disk creation, why is there a required VMID ? Is it not possible to create an unattached virtual disk that I would attach when needed to a virtual machine that I want (e.g I do not care about VMID and I would like to be able to attach the disk to a different VMID VM) ?

When we destroy the Virtual Machine, only attached disks are destroyed as well and it seems there is no option to control that unless detaching the disk before deletion unless I missed something.

E.g the virtual disk created by the CLI (or corresponding API) call
Bash:
pvesh create /nodes/{node}/storage/{storage}/content --filename vm-{vmid}-file --size 20G --vmid {vmid}
is destroyed if during virtual machine deletion if it is attached through
Bash:
pvesh create /nodes/{node}/qemu/{vmid}/config --scsi0 dell-storage:vm-{vmid}-file

Would it be possible to add an option which keeps the disks images in the storage even if they are referenced/attached ?

Or, maybe there would better options for doing what I'm trying to do ?

EDIT : My request would be to include an optional parameter in this CLI/API call : Proxmox API
Bash:
unregister  |  Force virtual disk unregister. Without this, the virtual disk is still referenced in the configuration and will be deleted if the virtual machine is deleted.
 
Last edited:
After more digging, it seems that unlinking a virtual disk through the unlink CLI/API could be done with this call as well :
Bash:
pvesh create /nodes/peuplier/qemu/12222/config --delete scsi0

As far as I can tell, it doesn't seem that Proxmox developers intended to support such feature as removing a disk image reference without deleting the actual disk image.

I really hope that it would be implemented some day through CLI/API calls instead of manually editing configuration files so that I can still use IaC tools to handle virtual disks as data disks.

I wonder if I should create a ticket for this.