How to Remove an Inaccessible Datastore in VMware
There are a lot of times when I am working in the home lab and removing things and adding things, changing hardware, etc and you get things in a funky state when it comes to datastores and other configuration. I wanted to walk through with you guys removing an inaccessible VMware as this is probably something you will need to do not only in the home lab but at some point in production.
Table of contents
What is an inaccessible datastore?
An inaccessible datastore is one that is pretty intuitive in what it is. You can see in the image below, that an inaccessible datastore is one that is noted that way in the storage tab in the vSphere client. It will show up in italics compared to the others, and it will have the (inaccessible) designation next to it.
You would think you can just right-click the datastore and select “remove from inventory” or something similar. However, this option is greyed out. Let’s see if we can forcibly remove it.
Using the vCenter MOB interface
Let’s see if we can use the vCenter MOB interface (https://<your vcenter address/mob) to remove the inaccessible datastore. Once logged in, select the content option in mob.
Next, select the Datacenters option.
Next, select the childEntity which for me is CloudLocal my datacenter name.
Under datastore you will see the datastore in question listed. Click the link next to the datastore.
Now we have several methods available to us. We want to use the DestroyDatastore option to see if we can get rid of the entry that way.
When you click it, you will see the below screen. Here we click Invoke Method.
Ah, now we are seeing the reason why the datastore won’t go away. We are getting a ResourceInUse error.
Resource in use – what?
So, now we are getting to the bottom of why the datastore won’t go away since it is inaccessible. We have a resource that is latched on to the datastore. Actually, when I had the datastore in inventory and everything was healthy, there was a vCLS VM that was using the datastore. When the datastore went inaccessible (I removed the NVMe drive), this vCLS VM was stuck in inventory in a disconnected state.
I couldn’t remove the vCLS virtual machine from inventory in the vSphere Client. So I went over to the host client, and sure enough, I could unregister it here.
Now that the vCLS VM is unregistered from the host client side, the vSphere Client shows it as removed as well.
Also, once I got rid of the stuck vCLS virtual machine, the datastore went away on its own.
Wrapping up
If you have ran into this issue either in the home lab or production, you need to first look at the resources that may still be stuck to the datastore. There are common culprits that will cause this issue, including virtual machines (like shown above with the vCLS machine), also ISO images are things that get forgotten about with a stuck datastore. Usually, VMware vSphere does a good job of getting rid of things on its own without manual intervention. However, you can use the MOB for vCenter Server to forcibly remove the datastore, if you don’t have resources that are latching on to it as I had.