Pcornel
Virtualization · Virtual Machine Lifecycle

Delete

Cheat sheet · https://pcornel.dk/topic.php?topic=3442

Back to the Topic

Answer

Deleting a VM removes it from inventory and, depending on the option, its disk files too (Delete from disk vs Remove from inventory, virsh undefine --remove-all-storage). Confirm backups and dependencies first; disk deletion is permanent.

Remember

  • Confirm a backup exists before deleting from disk.

First checks

  • virsh undefine <vm> --remove-all-storage — delete VM and disks (libvirt)
  • qm destroy <vmid> --purge — delete (Proxmox)
  • Remove-VM <vm>; then delete VHDX files — Hyper-V keeps disks unless removed

Commands

virsh undefine web01 --remove-all-storage --nvram
virsh undefine web01 --nvram
qm destroy 123 --purge 1 --destroy-unreferenced-disks 1
virsh detach-disk web01 vdb --config
virsh undefine vm01 --remove-all-storage
qm destroy 101 --purge

Verify in this order

confirmation → backups checked → VM and disks removed → references cleaned

Where it usually breaks

First mismatch in management intent → host/cluster capability → hypervisor runtime/task → virtual resource/device → guest state → workload-visible read-back; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3442

Confirmation

Confirm action

Continue?