I recently had an issue where I was unable to remove a datastore from the vCenter Server Inventory. The datastore was grayed out and when right-clicking, had no options. After some digging and some research in SQL, I found a way to manually do this in the vCenter database. Every datastore is given a unique ID and can be found and removed inside of the database.
Warning: Always make a SQL backup before attempting any manual database changes. You never know when things might break and you need to restore.
So here we go:
- Stop the vCenter Server Service
- Open SQL Management Studio
- Run the following against your vCenter Server database (This will give you the datastore ID):
select ID from VPX_ENTITY where name = ‘datastore_name’
- Now we have the ID and can remove it from the database
- Run the following 3 queries individually (Using the ID we got from the previous query):
delete from VPX_DS_ASSIGNMENT where DS_ID=ID;
delete from VPX_VM_DS_SPACE where DS_ID=ID;
delete from VPX_DATASTORE where ID=ID;
- Finally, run the following:
delete from VPX_ENTITY where ID=ID;
If you want to verify that everything went correctly, you can run the following:
select * from VPX_DS_ASSIGNMENT where DS_ID=ID; select * from VPX_VM_DS_SPACE where DS_ID=ID; select * from VPX_DATASTORE where ID=ID; select * from VPX_ENTITY where ID=ID;Now you’ve removed the datastore from the database and can start the vCenter Server Service again. If you don’t see that it has been removed, a reboot may help. I rebooted my server just to be on the safe side.
You can check out this VMware KB for more info.