Delete Orphaned Virtual Disks for a VM
search cancel

Delete Orphaned Virtual Disks for a VM

book

Article ID: 425198

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Symptoms:

  • Discrepancy between datastore "Used Space" and the actual size of active VM disks.

  • Necessity to identify and delete unmapped  virtual disks that were not removed during previous VM hardware reconfigurations.

  • Need to reclaim storage by purging detached virtual disks that are no longer providing value to the production environment.

  • "Zombie" or "Ghost" disks in the Datastore Browser that do not appear in any VM's Edit Settings menu.

Environment

vSphere vCenter 8.0

vSphere ESXi 8.0

Cause

Orphaned VM disk files may be left behind on a datastore following an incomplete Storage vMotion or disk cloning operation.

Resolution

Note: Before deleting any files, it is critical to verify the content to ensure no data loss occurs. Follow these steps to safely identify and reclaim the space:

To obtain a list of all disks attached to a specific Virtual Machine (VM) using both the User Interface (UI) and Command Line (CLI) for both vCenter and an ESXi host.

1. vCenter UI (vSphere Client)

  • Log in to the vSphere Client (HTML5).
  • Navigate to the VMs and Templates view (or use the search bar to find your VM).
  • Select the VM from the inventory.
  • Right-click the VM and select Edit Settings.
  • In the Virtual Hardware tab, you will see a list of all devices.
  • Look for entries named Hard disk 1, Hard disk 2, etc.
  • Click the expand arrow (>) next to each hard disk to view the exact Disk File path (the datastore and VMDK name), disk size, and sharing status.

 

2. ESXi UI (VMware Host Client)

If you are directly logged into the ESXi host where the VM is registered:

  • Open a web browser and log in to the ESXi Host Client (https://<ESXi-Hostname>).
  • Click on Virtual Machines in the left-hand Navigator pane.
  • Select the target VM from the list.
  • Right-click the VM and choose Edit settings.
  • Look for the Hard disk entries.
  • Click the expand arrow (>) to see the full path to the .vmdk backing file.

3. ESXi Command Line (SSH / ESXi Shell)

SSH directly into the ESXi host

Using vim-cmd (Queries the active VM registration)

  • First, find the VM's ID (VMID):

# vim-cmd vmsvc/getallvms | grep -i "YourVMName"
(Note the number in the very first column. This is your VMID).

  • Use that VMID to query the virtual hardware devices (Replace <VMID> with the number):

# vim-cmd vmsvc/device.getdevices <VMID> | grep -A 4 -i "VirtualDisk"

  • Go to the vmx path and run the following command to list all the disks attached to it

# less *.vmx | grep -i vmdk

This will print the Virtual Disk blocks, showing the fileName which contains the datastore path.

Refer to this article to retrieve all VM and template disk paths and determine if a specific VMDK is currently in use - To verify if a VMDK in a datastore is attached to any virtual machine or template

Clean up Snapshots and "Ghost" Files

If the disk is verified as unnecessary:

  1. Consolidate Snapshots: If the VM attached to that datastore has active snapshots, perform a Delete All Snapshots to merge data and release locked blocks.

  2. Storage vMotion: The most effective way to clear "leftover" files is to migrate the active VM to a different datastore.

    • Right-click the VM > Migrate > Change Storage Only.

    • VMware will only move files explicitly listed in the .vmx file.

    • Any files remaining on the Source Datastore after the migration are confirmed "orphans" and can be safely deleted.

Steps for Deletion via Datastore Browser once the vmdk is confirmed to be an orphaned disk no longer required and not attached to any VM's:

  1. Open the Datastore Browser.

  2. Locate and open the folder containing the orphaned files.

  3. Select the target .vmdk file

  4. Click Delete (or right-click and select Delete File).

 

 

Additional Information

Warning: Always ensure you have a valid full backup of the environment before manually deleting files from a datastore. If the file is a "Base" disk for a linked clone, deleting it could corrupt multiple VMs.