When attempting to delete VM folders from a datastore, the operation fails and an error message appears, " Deletion of file or directory [DatastoreX] vmname.3.vmdk from DatastoreX was initiated from 'Vmware vim-java [email protected]' and completed with status 'Failure' "
VMware vSphere ESXi (All Versions)
vSAN (All Versions)
The error is caused by remnants or locks left behind after a Virtual Machine (VM) has been removed from inventory. This includes hidden files, stale locks, or VM files protected by a configuration flag.
The general approach is to use the ESXi Command Line Interface (CLI) to manually clean up hidden or locked files, addressing the specific cause for the deletion failure.
| Solution Step |
Description |
Broadcom Reference |
| Use osfs-rmdir for Empty Folders |
If the VM folder is empty after removing the VM from inventory, you can attempt to remove the folder using the VSAN file system command from an ESXi SSH session. **Caution:** Be precise with the folder name. |
Remove an empty folder from vSAN datastore after VM deleted by external application. |
| Remove Hidden .lck Files | If the folder deletion fails because it's not truly empty (i.e., contains hidden files like stale locks), you must manually find and remove these lock files (.lck extensions). This may involve finding and running an owner abdication on the vSAN object. | Unable to delete VM folder from vSAN datastore - Broadcom support portal |
| Delete Remaining Files and Retry | If the folder still cannot be deleted, you may need to navigate into the folder via SSH, confirm any files are not in use, and use the rm command to delete the remaining files before retrying the osfs-rmdir command from the parent directory. | Unable to delete VM folder from vSAN datastore |
| Check for ddb.deletable = false Flag | If the VMs were created by VMware Horizon VDI, they might have a protection flag (ddb.deletable = false) in the VMDK descriptor. You can use a sed command via SSH to remove this line from all VMDK descriptor files in the VM namespace, and then attempt deletion via vSphere Client. | Many deleted VMs are still showing in the vSAN Datastore |
| Verify VM is Not Registered/Powered On | A generic error when deleting a file or folder often indicates that a registered or powered-on VM is still associated with it, preventing deletion. Ensure the VM is fully removed from inventory. | Cannot delete a vsan folder or file, error "Cannot delete file [vsanDatastore] <Namespace UUID>" |
**Important Safety Notice:**
All command-line operations carry a risk of data loss. If you are unsure about any of the steps, the Broadcom articles universally recommend opening a case with Broadcom Support for assistance.