To resolve this issue, the datastore references can be manually removed from the vCenter Server Inventory.
Important Note:
- Before attempting the steps below, please ensure to back up vCenter Server Appliance, or take an offline snapshot of the VCSA. Please be also aware that if the vCenter Server Appliance is a a member of an Enhanced Linked Mode (ELM) replication group, offline snapshots for all of the ELM nodes must be taken.
- Ensure that the datastore is not referenced by any virtual machine or VM template, either directly or because an ISO is mounted to the VM that was located on the datastore
- If there are ISOs attached to VMs or templates attached to the datastore, removing the VM/Template from inventory may resolve the issue.
To manually remove the datastore references from the Inventory:
- Stop the VMware VirtualCenter Server (vpxd) service on the vCenter Server:
# service-control --stop vmware-vpxd
- Connect to the vCenter Server database by running the following command:
# /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres
- Replace <datastore_name> in the following query against the actual datastore name and run the query to identify the ID of the datastore:
select ID from VPX_ENTITY where name ='<datastore_name>';
- Use the ID from previous step to remove the datastore reference to delete the datastore from database (replace <id> against the value received in step 3):
# 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>;
- Run this query to delete the datastore from the entity table (again replace <id> against the value received in step 3):
delete from VPX_ENTITY where ID=<id>;
- To verify, that the datastore has been removed from the database, the following commands, using the ID from step 3 in place <id>, should not display any results:
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>;
- Start the VMware VirtualCenter Server (vpxd) service:
service-control --start vmware-vpxd