Mapping a Linux guest OS disk to its corresponding virtual machine VMDK file.
search cancel

Mapping a Linux guest OS disk to its corresponding virtual machine VMDK file.

book

Article ID: 418101

calendar_today

Updated On:

Products

VMware vSphere ESXi

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.
  • This article provides a reliable method to establish a direct mapping between the Linux guest device (e.g., /dev/sd*) and its respective VMDK file.

Environment

vSphere ESXi 7.x
vSphere ESXi 8.x

Cause

By default, the device naming conventions (like /dev/sda, /dev/sdb) used by the Linux guest OS may change upon reboot or are simply not directly linked to the unique identifiers used by VMware (such as the VMDK's UUID). This lack of a consistent, shared identifier can lead to misidentification when performing critical disk management operations.

Resolution

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

Step 1: Enable Disk UUID attribute on the Linux 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:

  • Retrieve the WWID (World Wide Identifier) from the disk inside the Linux Guest OS: Run the following command, replacing " * " with the disk device you need to identify (e.g., sdb):
    • scsi_id --whitelisted --device=/dev/sd*
       
      • Example output: 3################################
  • 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 get uuid /vmfs/volumes/<Datastore Name>/<VM>/<VM>.vmdk
       
      • Example output: ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
  • Match the Identifiers:
    The output from scsi_id (the WWID) and the output from vmkfstools (the UUID) can now be matched to correctly identify the OS device and its corresponding VMDK file.

Note: The leading '3' in the scsi_id output and any spaces in the vmkfstools output must be disregarded for a successful comparison.