Mapping disk in Windows to its corresponding virtual machine VMDK file.
search cancel

Mapping disk in Windows to its corresponding virtual machine VMDK file.

book

Article ID: 432156

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • When managing virtual machines with multiple attached hard disks, accurately identifying the corresponding virtual disk file (VMDK) for a device listed within the guest operating system is critical.
  • This is particularly important for maintenance tasks, such as safely removing a specific hard disk from the virtual machine, preventing accidental deletion of the wrong disk.

Environment

VMware Cloud Foundation

vSphere

Resolution

Below steps involves enabling a persistent disk identifier (UUID) in the VM configuration and then retrieving and comparing two unique IDs: the "Serial Number" from the guest OS and the UUID from the virtual machine VMDK file.


Step 1: Enable Disk UUID attribute on the Windows VM

  • Power off the target virtual machine.
  • In vCenter, right-click the VM and select Edit Settings.
  • Select Advanced Parameters.
  • In the Key column, type: disk.enableUUID
  • In the Value column, type: TRUE and then click ADD
  • Click OK, and then Save the VM settings.
  • Power on the virtual machine.

Step 2: Map the OS disk to the VMDK UUID

Once the VM is powered on, retrieve the identifiers and match them:

  • Execute Powershell command "Get-Disk" then record the content in the column "Serial Number"        

    After performing Step 1, SSH into the ESXi host running the VM. Then, retrieve the UUID from the VMDK file(s) by executing the following command:
        vmkfstools -J getuuid /vmfs/volumes/<Datastore Name>/<VM>/<VM>.vmdk
         
            Example output: ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

    Match the Identifiers:
    The output from "Get-Disk" (Serial Number) and the output from vmkfstools (the UUID) can now be matched to correctly identify the OS device and its corresponding VMDK file.