×


Match Windows Disks to VMWare VMDK Files

Trying to match Windows Disks to VMWare VMDK Files?

This guide is for you.


Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to match windows disk and Virtual disks on a VMWare.

In this context, we shall look into the steps to match Windows disks and virtual disks (VMDK) on a VMWare VM.


When do we Match Windows Disks to VMWare VMDK Files?

While expanding the disk size of a VMWare virtual machine or deleting a disk, it is difficult to understand which VMware virtual disk matches the specific Windows VM disk.

When there are few disks, and they differ by their size, it is easy to find the disk we need.

But if there are several VMDK (or RDM) disks of the same size or several virtual SCSI controllers are there in a VM we will need to match the Windows disk to avoid errors.


How to Get SCSI Device Number in Windows and VMWare?

Small Computer System Interface (SCSI) number can be found with some easy and quick steps.


The steps to follow are given below:

1. First open the Disk Management console (diskmgmt.msc) in Windows.

The SCSI controller name and SCSI device number are not displayed in the list of disks.


2. Then to get the SCSI device number, we can right-click a disk and select Properties.

We can see the device port for VMWare Virtual disk SCSI Disk Device is shown in the Location field of the General tab.

Finally by combining the information we will get the SCSI disk address: SCSI(0:1).

After that, we need to open the virtual machine properties in the VMWare vSphere Client.

And then find the disk that has the same Virtual Device Node number as the ID we have got. In our example, it is SCSI(0:1) Hard Disk 2.


If multiple virtual disks with different SCSI controllers are configured on a virtual machine.

Also, it is difficult to find the SCSI device number manually.

The SCSI controller numbers in Windows and VMWare will differ usually.


[Need urgent assistance to perform VMWARE related tasks? We can help you!]


How to Match Windows Disk with VMDK by UUID/Serial Number Using PowerShell ?

One of the methods to map VMWare virtual disks to disks inside a guest VM is to compare their unique disk IDs

In VMWare this attribute is usually known as UUID (Unique ID), and in Windows – a Serial Number.


How to get UUID and SerialNumber of a virtual disk using PowerShell?

Generally, all VMWare VMs have the disk EnableUUID=TRUE parameter enabled.

And to get information about disks in Windows, we can use the Storage module cmdlets or WMI queries.

If we have some VMs running Windows Server which does not have the Storage module, we will use WMI.

Run the following PowerShell command to get a SCSI controller number or a SCSI device number:


$DiskInfo = foreach ($disk in Get-WmiObject Win32_DiskDrive) {
[pscustomobject]@{
"DeviceID"=$disk.DeviceID;
"Caption"=$disk.Caption;
"Capacity (GB)"=[math]::Round($disk.size / 1GB,0);
"SerialNumber" =$disk.SerialNumber
"SCSIControllerNum"=$disk.scsiport;
"SCSIDeviceNum"=$disk.scsitargetid;
}
}
$DiskInfo|ft

We will see the disks as listed below:

* PHYSICALDRIVE0: SCSI Port 0, SCSI Target 0, Serial 6000c2939b157427dadbace321ed4973
* PHYSICALDRIVE1: SCSI Port 0, SCSI Target 1, Serial 6000c2950ee961954909938642bb03b4
* PHYSICALDRIVE1: SCSI Port 4, SCSI Target 10, Serial 6000c2995fc3c4928d6650596bb02cef

Then let us try to get SCSI controller numbers and UUIDs of the disks specified in the settings of the VMWare virtual machine. To view the VM settings, use the PowerCLI console.

Import-Module VMware.VimAutomation.Core -ErrorAction SilentlyContinue
connect-viserver ber-vmware1
$vmName="ber-man01"
$vmHardDisks = Get-VM -Name $vmName | Get-HardDisk
$vmDatacenterView = Get-VM -Name $vmName | Get-Datacenter | Get-View
$virtualDiskManager = Get-View -Id VirtualDiskManager-virtualDiskManager
$vmresults = @()
foreach ($vmHardDisk in $vmHardDisks)
{
$string = $vmHardDisk.Filename
$vmHardDiskUuid = ($vmHardDisk.ExtensionData.Backing.Uuid | ForEach-Object {$_.replace(' ','').replace('-','')})
$vmresult = "" | Select-Object vmHardDiskDatastore,vmHardDiskVmdk,vmHardDiskName,vmHardDiskSize,vmHardDiskUuid
$vmresult.vmHardDiskDatastore = $vmHardDisk.filename.split(']')[0].split('[')[1]
$vmresult.vmHardDiskVmdk = $vmHardDisk.filename.split(']')[1].trim()
$vmresult.vmHardDiskName = $vmHardDisk.Name
$vmresult.vmHardDiskSize = $vmHardDisk.CapacityGB
$vmresult.vmHardDiskUuid = $vmHardDiskUuid
$vmresults += $vmresult
}
$vmresults | ft

This script will connect to the vCenter (or ESXi) server and get the list of disks for the specified VM.

And the result will have  DataStore name, VMDK file path, disk number, disk size and UUID.

Finally, we can manually match the disks we see in the guest Windows OS with VMWare virtual disks by their UUIDs.


[Need assistance to perform Software installation on Linux Server? We can help you!]


Conclusion

This article will guide you on the steps to match #windows #disks to #VMWare #VMDK files.