VMware Cloud Community
jitu110067
Contributor
Contributor

Duplicate disk UUID generation from VM template

Hi,

It is the tendency of a vm template that when you deploy any vm from them it keeps the disk uuid same for all deployed VMs.

This duplicate UUID creates problem in taking the backup from any backup tool (i.e PHDVBA).

Can some one have the solution for the template that everytime when we deploy any vm from template it could generate unique disk UUID.

Thanks.

Reply
0 Kudos
6 Replies
vNEX
Expert
Expert

Hi,

for workaround refer to this KB article:

VMware KB: Duplicate VMDK UUIDs are created when virtual machines are deployed from a template

_________________________________________________________________________________________ If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards, P.
Reply
0 Kudos
jitu110067
Contributor
Contributor

Thanks for your reply.

I already have gone through the KB.  I am looking for any solution that could be injected within the template.

Reply
0 Kudos
vNEX
Expert
Expert

I don't know any vmx parameter that would define this... but you can accomplish some automation with PowerCLI script below.

Using New-VM cmdlet and with help of this script: Change VMDK UUID using PowerCLI | Virtual Chris you can change (right after VM creation) ddb.UUID of vmdk specified:

$SRVA = "<New VM Name>"
$DS = "<DATASTORE NAME>"

New-VM -vmhost azphht70.cnb.cz -Name $SRVA -Template "New Virtual Machine" -Datastore $DS


function get-HalfVMwareUUID() {

$testguid=[Guid]::NewGuid()
$strGuid=[string]$testguid
$arrGuid=$strGuid.split("-")
$secondHalfTemp=$arrGuid[3]+$arrGuid[4]
$secondHalf=$secondHalfTemp[0]+$secondHalfTemp[1]+" "+$secondHalfTemp[2]+$secondHalfTemp[3]+" "+$secondHalfTemp[4]+$secondHalfTemp[5]+" "+$secondHalfTemp[6]+$secondHalfTemp[7]+" "+$secondHalfTemp[8]+$secondHalfTemp[9]+" "+$secondHalfTemp[10]+$secondHalfTemp[11]+" "+$secondHalfTemp[12]+$secondHalfTemp[13]+" "+$secondHalfTemp[14]+$secondHalfTemp[15]
  $secondHalf
}


[string] $oldUUID = $vdm = get-view -id (get-view serviceinstance).content.virtualdiskmanager

$dcid=get-datacenter | Select id

$filePath="[$DS]/$SRVA/$SRVA.vmdk"

$oldUUID=$vdm.queryvirtualdiskuuid($filePath, $dcid.id)
Write-Host "Old UUID $oldUUID"
[string] $firstHalf = $oldUUID.split("-")[0]
[string] $halfUUID = get-HalfVmwareUUID

$vdm.setVirtualDiskUuid($filePath, $dcid.id, $firstHalf+"-"+$halfUUID)
$newUUID=$vdm.queryvirtualdiskuuid($filePath, $dcid.id)
Write-Host "New UUID $newuuid"

Its  just a very simple sample....:) undoubtedly it can be modified to suit for much larger deployments with much more VMs in a row and with some additional comfort.

_________________________________________________________________________________________ If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards, P.
Reply
0 Kudos
kumasam4
Contributor
Contributor

Hi,

This script looks good.
While running this script, it throws an exception

Exception calling "QueryVirtualDiskUuid" with "2" argument(s): "The object 'vim.Datacenter:datacenter-942' has already been deleted or has

not been completely created"

At C:\soft\POWERSHELL-PNS\vCenter-ScalabilityTest.POWERSHELL_SCRIPT\updateVMDKUuid.ps1:133 char:5

+     $newUUID=$vdm.queryvirtualdiskuuid($filePath, $dcid)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

Exception calling "QueryVirtualDiskUuid" with "2" argument(s): "The object 'vim.Datacenter:datacenter-942' has already been deleted or has

not been completely created"

At C:\soft\POWERSHELL-PNS\vCenter-ScalabilityTest.POWERSHELL_SCRIPT\updateVMDKUuid.ps1:127 char:5

+     $oldUUID=$vdm.queryvirtualdiskuuid($filePath, $dcid)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

Could you please advise ?

Reply
0 Kudos
kumasam4
Contributor
Contributor

It seems like, it has privileges issues. It worked now.

Reply
0 Kudos
baszek
Enthusiast
Enthusiast

Is it still unsolved in vsphere 7 and above ? 

According to KB: 
Resolution
This is a known issue affecting vSphere 4.x, 5.x and 6.x. Currently, there is no resolution.

Reply
0 Kudos