VM state invalid in vCenter inventory due to file lock from an ESX host
search cancel

VM state invalid in vCenter inventory due to file lock from an ESX host

book

Article ID: 424735

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

In VMware vCenter, a virtual machine (VM) may appear in an "invalid" state within the inventory. You may find yourself unable to re-register the VM because a specific ESXi host is holding a file lock on the VM’s configuration (vm-name.vmx) file. This issue can occur even if the host holding the lock is currently in maintenance mode.

Environment

  • VMware vSphere ESXi
  • VMware vCenter Server

Cause

An ESXi host maintains an active lock on the VM files, preventing other hosts from registering or managing the object. This typically happens if a VM process remains running on a host creating a mismatch between the host's actual state and the vCenter inventory.

Resolution

To resolve this issue, you must identify the host holding the lock and re-register the VM from that specific host.

  1. Identify the host holding the lock:

    Follow standard procedures to identify the MAC address of the host holding the lock by running vmkfstools -D against the VM's .vmx file and reviewing the vmkernel.log.

    vmkfstools -D /vmfs/volumes/<Datastore_Name>/<VM_Folder>/<VM_Name>.vmx
    tail /var/run/log/vmkernel.log

    Find the MAC Address of the host holding the lock as the last portion of the UUID. Example:
    <timestamp> In (182)| vmkernel: gen 37, mode 1, owner ########-########-####-001122334455 mtime 3890942

    This would equate to a MAC Address of 00:11:22:33:44:55 in the above example.

    Refer to Device or resource busy / file is locked error when making changes to a file on an ESXi datastore for further details.

  2. Access the host:

    Log in via SSH to the ESXi host identified by the MAC address.

  3. Exit Maintenance Mode:
        
    Take the ESXi host out of Maintenance Mode.

  4. Register the VM via CLI:
        
    Run the following command to manually register the VM on that host:

    vim-cmd solo/registervm /vmfs/volumes/<Datastore_Name>/<VM_Folder>/<VM_Name>.vmx

Additional Information