Unable to remove inaccessible datastore from vCenter server
search cancel

Unable to remove inaccessible datastore from vCenter server

book

Article ID: 320008

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Symptoms:

  • Datastore shows as (inaccessible) in the vCenter UI

  • No files are available in the vCenter UI for the respective datastore

  • There is an error: Datastore ‘{name}’ is not accessible or “No connected and accessible host is attached to the datastore.”

  • Datastores may show as accessible but will not have any reference to the ESXi hosts or virtual machines.

Environment

VMware vCenter Server 6.5.x
VMware vCenter Server 6.7.x
VMware vCenter Server 7.x
VMware vCenter Server 8.x
VMware vCenter Server 9.0.x

Cause

This issue can be due to any of the following:

  • The underlying storage device or LUN associated with the datastore may have been removed, decommissioned, or failed without proper cleanup.

  • vCLS VMs were forcefully deleted from the VMs without the host being in Retreat Mode.

  • The vCenter database (VCDB) retains inaccessible datastore records when they are not properly removed, leaving objects in the environment.

Resolution

Perform a cluster level rescan on all the clusters where the datastore was mounted previously.

If after a cluster level rescan the inaccessible datastore entry is seen, proceed with the below steps.

Note : Make sure to take a snapshot or backup of the vCenter server before making any changes to the VCDB. If vCenter is in Enhanced Linked Mode (ELM), then take offline snapshots of all ELM partners before proceeding. See VMware vCenter in Enhanced Linked Mode pre-changes snapshot (online or offline) best practice

To identify and remove the objects completely from the VCDB: 

  • Stop the vpxd service:
    # service-control --stop vpxd
  • Connect to the vCenter database:
    # /opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres

  • Search for the inaccessible datastore entry in VCDB:
    VCDB=# SELECT id FROM vpx_entity WHERE name = 'Datastore Name';
  • Get the Datastore id to find which objects are seen by the database inside the Datastore:
Example: 
  id
--------
169867
(1 row)                                                                                                                            
Find if the id is being associated with objects which were present in the datastore:  
VCDB=# SELECT * FROM vpx_ds_assignment WHERE ds_id=169867; ds_id  | entity_id | accessible | mount_path | mount_id | mount_mode | mounted --------+-----------+------------+------------+----------+------------+--------- 169867 |    160136 |            |            |          |            | 169867 |    160148 |            |            |          |            | (2 rows)
  • The above shows two objects in the inventory that are still connected to the datastore. To find out the name of the objects:
    Example :
VCDB=# SELECT * FROM vpx_entity WHERE id=16##36;
   id   |       name        | type_id | parent_id
--------+-------------------+---------+-----------
160136  | <VM_Name>         |       0 |    161290
(1 row)

VCDB=# SELECT * FROM vpx_entity WHERE id=16##48;
   id   |      name        | type_id | parent_id
--------+------------------+---------+-----------
160148  | <VM_Name>        |       0 |    161290
(1 row)

  • Delete the objects one by one:

DELETE FROM vpx_vm_ds_space WHERE ds_id=169867; 
DELETE FROM vpx_ds_assignment WHERE ds_id=169867;
DELETE FROM vpx_datastore WHERE id=
169867;
DELETE FROM vpx_entity where id=169867;

Start the vpxd service for the vCenter:

# service-control --start vpxd

Additional Information

Additionally, if the datastore was removed or deleted from storage before removing from the host, and is now

 - showing as inaccessible from vCenter

 - is present but errors out when accessing from the host client

 - cannot be removed from vCenter or host client while failing with "Not a known device"

 - does NOT show from the host CLI

The issue may be resolved by rebooting the hosts showing the datastore attached.

Note: Please make sure that you remove the datastore assignments from the ESXi hosts at the backend storage level to prevent them from reappearing in vCenter.