I came across an interesting error attempting to delete am empty datastore from one of my VMware environments. Here’s the error I get:
The resource [datastore name] is in use.
- Version: ESXi 4.1
- Pesky Datastore: iSCSI SAN Volume
In use? But I moved everything off of the datastore and deleted the rest of the snapshot data and rubbish spread about the left over directories. What gives?
Datastores will still be in use if something is still pointing or mounted to them
Although you may not be dealing with a ISO issue, this KB article kind of explains how mounted items inhibit the ability for the datastores to be deleted:
As I’ve read though the KB articles and forums posts, I’ve found this to be the most prominent. Even though the files are gone, there still may be resources that believe they are mounted to something very real on the datastore.
To avoid going through every VM, take a look at your maps view and see if there is anything connected to the datastore you’re trying to get rid of. If it’s an offline VM that’s attached to it, you’ll have no problem seeing it there and knowing just how to take care of it. (The steps below that indicate how to remove a confused template can be used to remove and add a VM as well). For those of you that have command access to the host, give this a shot:
This will show you what items are registered with the datastore and may help to determine what to focus on during your hunt.
As painful as it sounds, you may have to check the settings of every VM recently associated with the datastore in question and see if there is still a CD Drive, mounted ISO, template, or hard drive pointing to it.
In my case, I found a template that was still convinced it’s hard drive was on the datastore. The steps to fix this were easy:
- Right click on the faulty template and choose “Remove From Inventory”
- Browse out to the datastore where the VM Template now resides
- Right click the .vmx file and choose “Add to Inventory”
Removing the template from inventory will finally release the datastore. If that’s the last thing attached to the datastore, you should be able to delete it now. Adding the template back to inventory puts your template back in your list, ready for use when you need it.