keepcalculator

06 Numbers and Powers

Delete Orphaned VM VMware: Safe Cleanup Steps

Card No. 06·81414 · Updated · Standard formula, shown below

To delete an orphaned VM in VMware, you must remove its leftover files from the datastore and then remove its stale entry from the vCenter inventory. This article explains exactly how to identify orphaned VMs, safely delete them, and avoid common pitfalls that can cause data loss or cluster issues.

What Is an Orphaned VM?

An orphaned VM is a virtual machine that appears in the vSphere Client inventory but is no longer registered on any ESXi host. This typically happens when a host fails, is disconnected, or is removed from the cluster while the VM’s configuration file (.vmx) remains on shared storage. The VM shows a grayed-out icon and a status of “Orphaned” or “Inaccessible” in the vCenter. It is important to understand that the VM’s files (disk, config, logs) are still on the datastore, so deleting the inventory entry alone does not free up storage space.

Why Delete Orphaned VMs?

Leaving orphaned VMs in your inventory can cause several problems:

  • Storage waste: The VM’s virtual disks (VMDK) continue to occupy space on the datastore, even though the VM is not running.
  • Inventory clutter: Orphaned entries make it harder to manage your actual VMs and can confuse automation scripts or monitoring tools.
  • Cluster issues: In some cases, orphaned VMs can interfere with VMware HA (High Availability) or DRS (Distributed Resource Scheduler) because the cluster still sees the VM’s resource reservations.
  • Snapshot problems: If the VM had snapshots, they are also orphaned and can consume significant disk space.

Deleting orphaned VMs is a common cleanup task for VMware administrators, especially after host failures or migrations.

How to Identify an Orphaned VM

Before you delete anything, you must confirm that the VM is truly orphaned and not just temporarily inaccessible. Follow these steps:

  1. Log in to the vSphere Client (web or desktop).
  2. Go to the Hosts and Clusters view and select the cluster or datacenter where the VM resides.
  3. Look for a VM with a grayed-out icon and a status of “Orphaned” or “Inaccessible” in the Status column.
  4. Right-click the VM and select Edit Settings. If the VM is orphaned, you will see an error like “The VM is not registered on any host.”
  5. Check the VM’s Summary tab: if it shows “Not connected” or “Orphaned,” it is a candidate for deletion.

If the VM is merely inaccessible due to a host failure, you might be able to re-register it once the host is back. Only delete if you are sure the VM is no longer needed or if you have already recovered its data.

Step-by-Step: Delete an Orphaned VM

Deleting an orphaned VM involves two separate actions: removing the inventory entry and deleting the files from the datastore. Here is the safe procedure:

  1. Remove from inventory: Right-click the orphaned VM in the vSphere Client and select Remove from Inventory. This only removes the VM entry from vCenter; it does not delete any files.
  2. Locate the VM’s files: Go to the Storage view, select the datastore where the VM resides, and browse the datastore to find the folder with the VM name (e.g., VMNAME).
  3. Verify the files: Inside the folder, you should see files like VMNAME.vmx, VMNAME.vmdk, and possibly VMNAME-000001.vmdk (snapshots). Double-check that the VM is not registered elsewhere (e.g., on a different host) before proceeding.
  4. Delete the folder: Right-click the folder and select Delete. Confirm the deletion. This permanently removes the VM’s files from the datastore.

If you are using the command-line interface, you can use the vmkfstools command to delete VMDK files, but the GUI method is safer for beginners.

What If the VM Is Still Registered?

Sometimes a VM appears orphaned but is actually still registered on a host that is temporarily disconnected. In that case, do not delete it. Instead:

  • Reconnect the host: Right-click the host in vCenter and select Connect.
  • If the host is permanently gone, you can remove the host from the cluster and then re-register the VM on another host.
  • To re-register a VM: Right-click the host, select Register VM, and browse to the .vmx file on the datastore.

If the VM is still running on a host that is not visible in vCenter (e.g., a standalone host), deleting its files would cause data loss. Always verify the VM is not in use.

Common Mistakes and How to Avoid Them

Deleting orphaned VMs is straightforward, but mistakes can be costly:

  • Deleting the wrong VM: Always double-check the VM name and its files before deleting. Use the datastore browser to confirm the folder matches the VM you intend to delete.
  • Forgetting snapshots: If the VM has snapshots, deleting the folder removes them too. This is usually fine, but if you need to keep a snapshot for recovery, copy the entire folder elsewhere first.
  • Not checking for linked clones: If the VM is a parent of a linked clone, deleting its disk will break the clone. Check for dependent VMs before deletion.
  • Using “Delete from Disk” instead of “Remove from Inventory”: If you right-click the VM and choose Delete from Disk, it will attempt to delete the files immediately, which may fail if the VM is orphaned. It is safer to remove from inventory first, then delete files manually.

Alternatives to Deleting: Re-registering or Archiving

If you are unsure whether the VM is needed, consider these alternatives:

  • Re-register the VM: If the VM is still valid, you can re-register it on a working host to bring it back into operation.
  • Archive the VM: Copy the VM’s folder to a backup datastore or external storage before deleting it from the production datastore. This preserves the VM for future use without consuming production space.
  • Export to OVF/OVA: Use the vSphere Client to export the VM as an OVF template, which you can store offline and re-import later.

These options are useful when you are not 100% certain that the VM is obsolete.

Frequently Asked Questions

Does removing an orphaned VM from inventory free up disk space?

No. Removing from inventory only removes the VM entry from vCenter. The VM’s files remain on the datastore and continue to consume space. You must delete the files from the datastore to reclaim storage.

Can I recover an orphaned VM after I delete it?

If you only removed the VM from inventory, you can re-register it by browsing to its .vmx file on the datastore. If you deleted the files, recovery is only possible if you have a backup or if the datastore uses snapshots or replication.

Why does my orphaned VM show as “Inaccessible” instead of “Orphaned”?

“Inaccessible” usually means the VM is registered on a host that is disconnected or the datastore is not mounted. “Orphaned” specifically means the VM is not registered on any host. Both can be deleted, but “Inaccessible” VMs may be recoverable by reconnecting the host or mounting the datastore.

Is it safe to delete an orphaned VM’s files directly from the datastore?

It is safe only if you have confirmed the VM is not registered elsewhere and you have verified that no other VM is using its disks (e.g., as a linked clone). Always back up the folder first if there is any doubt.

What is the difference between “Remove from Inventory” and “Delete from Disk”?

“Remove from Inventory” unregisters the VM from vCenter but keeps all files. “Delete from Disk” unregisters and deletes the VM’s files from the datastore. For orphaned VMs, “Delete from Disk” may fail because the VM is not registered, so it is safer to remove from inventory and then delete the files manually.

Will deleting an orphaned VM affect other VMs on the same datastore?

No, deleting a VM’s folder only removes that VM’s files. Other VMs on the same datastore are unaffected, unless they share disks (which is rare and not recommended).

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →