Device or resource busy when trying to delete vmdk on vmfs


When you try and delete an orphaned vmdk file you get the error:

rm: cannot remove `xxxxxxx-flat.vmdk': Device or resource busy

or

Cannot delete file [xxxxxx] xxxx/xxxx-flat.vmdk

This may be because

  • The file is being used and locked open by a running VM
  • The file is an orphan but is still locked by ESX

To check if the file is an orphan (zombie) download RVtools from

http://www.robware.net/

and click on the vHealth tab. All files that are potentially orphans are listed here.

If the vmdk is an orphan then one of the ESX hosts will be locking the file. Most likely you’ll have quite a few ESX hosts and rebooting each one until the file unlocks would be painful. Instead you can make use of vmkfstools:

SSH to each ESX host in turn and run the following command:

vmkfstools -L release /vmfs/volumes/xxxxxxxx/xxxxxxx/xxxxxx-flat.vmdk

There are two potential errors:

Could not open /vmfs/volumes/xxxxxxxx/xxxxxxx/xxxxxx-flat.vmdk
Command release failed
Error: Device or resource busy

or

Command release failed
Error: Inappropriate ioctl for device

The host that gives you this second error is the one that has locked the file.

Migrate off the VMs from the host and place it into maintenance mode and reboot it. Now try and delete the file that was locked. You should find that the file can now be deleted.

About these ads

6 thoughts on “Device or resource busy when trying to delete vmdk on vmfs

  1. Hi guys, you can also check out Powergui.
    http://www.powergui.org/downloads.jspa
    This will also show you orphaned files. Another thing to check is if any snapshots are preventing you to delete this file.

    And it has loads of pre-built scripts built in so that you don’t have to write your own PowerCLI scripts.

    Have a look. Very helpful to me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s