vm deletion while keeping disks

fonze98

Member
Oct 15, 2022
17
1
8
is it possible at all to delete a VM but keep a disk that was attached to the VM? Lets say I have a data disk assigned to a VM but want to blow that VM away and reconfigure it but keep the data disk around for the reconfigured VM. I do not see any way of doing this currently without already having a new VM to reassign the disk to.
 
Ok maybe I am not following fully, I have detached the disk from the VM so that it now shows up in the hardware list and is listed as Unused Disk 0. When I go and remove the VM, enter the ID to confirm the Purge and Destroy options are unchecked. That disk is now deleted along with the VM.
 
That's why I said should. I wasn't certain. I suppose you'll have to totally remove the reference to the disk then.
 
In the "Disc Action" menu of that virtual disk you'll find "Reassign Owner". (A temporary "dummy"-VM" is sufficient.) Then deleting the original VM won't touch that virtual disk any more...
 
  • Like
Reactions: narrateourale
Ok maybe I am not following fully, I have detached the disk from the VM so that it now shows up in the hardware list and is listed as Unused Disk 0. When I go and remove the VM, enter the ID to confirm the Purge and Destroy options are unchecked. That disk is now deleted along with the VM.
That's unexpected. When 'Destroy unreferenced disks owned by guest' is unchecked the virtual disk should still be on the underlying storage. Otherwise report a bug at https://bugzilla.proxmox.com . What storage type are you using? Do the detached drives not show in VM Disk view under the storage? They are not automatically shown when you create a VM with the same ID; a qm disk rescan or similar is required.
 
Yep I have a three node ceph pool and a 4th node that is just using local storage. I have tested this on both the ceph pool and local storage. When I create the VM and add the second hard disk it shows up in the VM Disks section. After Detaching the disk, I can still see it in the VM Disks section and upon VM removal with both boxes unchecked the drive is removed along with the VM and no longer appears in the list of disks in the VM Disks section. I have tested this in both a cluster and standalone PVE configuration both on the ceph pool and the local storage
 
Hi,

"Unused" disk are still referenced in the config, so it will be deleted even if you don't tick the box.

It's not a bug; it's how it's supposed to work.

From the CLI manual (which is the same as using the GUI) :
qm destroy <vmid> [OPTIONS]

Destroy the VM and all used/owned volumes. Removes any VM specificpermissions and firewall rules

<vmid>: <integer> (100 - 999999999)
The (unique) ID of the VM.

--destroy-unreferenced-disks <boolean> (default =0)
If set, destroy additionally all disks not referenced in the config but with a matching VMID from all enabled storages.

--purge <boolean>
Remove VMID from configurations, like backup & replication jobs and HA.
Cf : https://pve.proxmox.com/pve-docs/pv...ng_qm_strong_qemu_kvm_virtual_machine_manager

You either have to move the disk to another VM, or delete the "unused" from the config file.

Best regards,
 
  • Like
Reactions: UdoB and leesteken