Deleting a vmdk file for a virtual machine that is no longer used fails: Device or resource busy
search cancel

Deleting a vmdk file for a virtual machine that is no longer used fails: Device or resource busy

book

Article ID: 339979

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

Symptoms:
  • You have a virtual machine folder on a datastore, for a virtual machine that has been deleted.
  • When you right-click on a virtual machine's virtual disk file, the Delete option is not available (greyed out).
  • Attempting to remove the virtual disk file fails, even though
    • There is no lock on the virtual disk file.
    • There is no process that has locked the virtual disk file.
       
  • Attempting to removing the virtual disk file fails with the error:

    Device or resource busy.
     


Environment

VMware vSphere ESXi 6.5
VMware vSphere ESXi 6.7
VMware vSphere ESXi 6.0

Resolution

Some virtual machine backup solutions, as part of their backup approach, mount a virtual machine's virtual disk file (.vmdk) to a virtual machine other than the one the .vmdk originally belonged to. When this happens, the .vmdk whose parent virtual machine had been deleted is still mounted to a running virtual machine. Even though the .vmdk file is not technically open, it is mounted to the backup solution's virtual machine.
 
To resolve this issue, you must locate the virtual machine that has this .vmdk mounted and then unmount it. To do so:
  1. Search for references to the .vmdk file in the settings files (.vmx files) of the other virtual machine's on the datastore. You can automate the search with a command like this:

    find /vmfs/volumes/* -name *.vmx -exec grep -Hi <name-of-the-file.vmdk> {} \;

    where <name-of-the-file.vmdk> is the .vmdk you're trying to delete.

    Note: You need to run this command from each host that can see the datastore, because the .vmx file is locked on all hosts except the one on which it is running.
     
  2. After you have located the virtual machine which has mounted the .vmdk, remove it. Select that virtual machine and go to Edit Settings > Hard Disk > Remove.

After you have removed the .vmdk file from the backup virtual machine, you can delete the file using normal methods.

NOTE:  Before deleting the VM/VMDK. Make sure the VM or VMDK which you are deleting is not part of backup or added to proxy server.


Additional Information

使用されなくなった仮想マシンの vmdk ファイルの削除が次のエラーで失敗する:デバイスまたはリソースが使用中です
为虚拟机删除不再使用的 vmdk 文件失败:设备或资源繁忙 (Device or resource busy)