How to validate if a VM is using a vmdk file by analysing the vmx file
search cancel

How to validate if a VM is using a vmdk file by analysing the vmx file

book

Article ID: 430686

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • There are vmdk files in the VM directory which are suspected to be orphans but that needs to be validated.
  • This KB provides steps that can be used to validate which vmdk files are being used by the VM.
  • The directory path to the VM directory on the ESX host will be the following:
    /vmfs/volumes/DatastoreName/VMFolderName

Environment

VMware vCenter Server

Resolution

  • To validate if a virtual machine is utilizing a specific .vmdk file by analyzing the .vmx configuration file, you must search for the fileName parameter associated with the virtual device controllers (SCSI, IDE, or NVMe).
  • If the vmdk file is not referenced in the .vmx file, then it is not currently being used by the VM. 
  • The directory path to the .vmx file on the ESX host will be the following:
    /vmfs/volumes/DatastoreName/VMFolderName/VMName.vmx
     
  • Manual Validation Steps:
    1. Open the .vmx file: Use a text editor (e.g., Notepad++, vi, or Nano).
    2. Locate Disk Controllers: Search for entries starting with scsi, ide, or nvme.
    3. Identify the Filename: Look for the .fileName key associated with a specific vmdk number.

Example Entry:
scsi0:0.present = "TRUE"
scsi0:0.deviceType = "scsi-hardDisk"
scsi0:0.fileName = "VirtualDiskName.vmdk"

  • Key Parameters to Inspect:
    • present = "TRUE": Confirms the device slot is active.
    • deviceType = "scsi-hardDisk": Ensures the device is a disk and not a CD-ROM/ISO.
    • fileName: The value here is the relative or absolute path to the .vmdk descriptor file.

  • Advanced Validation via Command Line:
    If you are logged into an ESXi host via SSH, you can quickly grep the file:

    grep -i ".vmdk" /vmfs/volumes/DatastoreName/VMFolderName/VMName.vmx

Important Considerations:

  • Snapshots: If the VM has active snapshots, the .vmx file will point to a delta disk (e.g., VMName-000001.vmdk) instead of the base disk.
  • Absolute vs. Relative Paths: If the .vmdk is in the same folder as the .vmx, only the filename is shown. If it resides on a different datastore, the full path (starting with /vmfs/volumes/...) will be present.
  • Multiple Disks: A VM can have multiple disks. Ensure you check all controller increments (e.g., scsi0:0, scsi0:1, scsi1:0).

Additional Information

  • The last write\modify time for a vmdk file or its associated data flat.vmdk file can be verified using the following command:
    - stat <filename>.vmdk
    - stat <filename>-flat.vmdk