Use this when removing a VM safely, including its disks, backups, DNS, IPAM and monitoring entries.
Delete
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.
1. Confirm backups and owner first.
2. Know whether disks are deleted with the VM.
3. Remove from backup jobs, HA and monitoring.
4. Release IPs and DNS.
5. Check for orphan disks later.
confirmation → backups checked → VM and disks removed → references cleaned
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Before deleting Verify boundary
- Recent backup exists and is restorable.
- No other VM uses its disks (linked clones, shared disks).
- Owner confirmed.
Step 2 Common mistakes Narrow the fault
- Removing from inventory and assuming files were deleted.
- Deleting a parent of linked clones.
Step 3 Things to know Narrow the fault
- Confirm a backup exists before deleting.
- Hyper-V leaves disk files behind; vSphere "Remove from inventory" leaves files too.
- Clean up DNS, monitoring, backup jobs and IPAM entries.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Confirm a backup exists before deleting from disk.
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
ReferenceImportant terms & boundaries3 sections · depth on demand
In depth
Delete completely — and only what you mean to
| Platform | Command | Removes |
|---|---|---|
| libvirt | virsh undefine web01 --remove-all-storage --nvram | Definition, all disks listed in the XML, UEFI NVRAM file |
| libvirt (keep disks) | virsh undefine web01 --nvram | Definition only — disks remain as orphans |
| Proxmox VE | qm destroy 123 --purge 1 --destroy-unreferenced-disks 1 | Config, disks, and references in backup jobs, replication and HA |
--remove-all-storage deletes every disk in the definition, including shared or attached data disks. Check first:
# virsh domblklist web01 --details
Type Device Target Source
------------------------------------------------------------
file disk vda /var/lib/libvirt/images/web01.qcow2
file disk vdb /srv/shared/data-common.qcow2
file cdrom sda /var/lib/libvirt/boot/debian.iso
Here vdb is shared — detach it (virsh detach-disk web01 vdb --config) before undefining with storage removal.
Pre-delete checklist
| Check | Reason |
|---|---|
| Final backup kept with a retention that outlives the VM | Accidental or premature deletion |
| Linked clones that use this VM as a template | Deleting breaks them |
| DNS records, DHCP reservations, monitoring, firewall objects | Stale references cause confusion and IP reuse problems |
| Licences and certificates bound to the VM | Reclaim or revoke |
| CMDB / inventory | Keep records accurate |
Orphans after incomplete deletes
Disks left behind consume storage silently:
pvesm list local-zfs | grep -v -E 'vm-(101|102|...)-' # Proxmox: volumes not owned by existing VMs
qm rescan # attach unreferenced disks as unused to their VMs
virsh vol-list default # libvirt: compare with domblklist of all domains
Treat deletion as a change: schedule it, notify owners, keep the backup, and remove references in the same change.
*The virtual disk inventory and orphan-volume checks above are illustrative examples, not captured from a lab or production host.*
Commands
| Platform | Command |
|---|---|
| KVM/libvirt | virsh undefine vm01 --remove-all-storage |
| Proxmox | qm destroy 101 --purge |
| Hyper-V | Remove-VM vm01 (disks stay — delete the VHDX files separately) |
| vSphere | Remove-VM vm01 -DeletePermanently |
Method
Deleting a VM removes its configuration and, usually, its disks. Before deleting:
1. Confirm the VM ID/name and owner — similar names are a classic error.
2. Check for snapshots, replication jobs, backup jobs and HA rules that reference it.
3. Decide whether to keep a final backup.
4. Remove it from monitoring, DNS, CMDB and firewall rules.
qm destroy 120 --purge --destroy-unreferenced-disks 1
virsh undefine vm1 --remove-all-storage --nvram
Remove-VM vm1 # Hyper-V keeps VHDX files — delete them separately
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Virtual Machine Lifecycle → Delete. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/docs.html · confidence 94%