Live migration fails of Private Cloud VMs after using PDT

no-live-migrationIf you try to live migrate the Private Cloud VMs after using the PDT VMCreator.ps1 you’ll get an error similar to this:

The reason is that the OS disk in each of the 15 VMs is a differencing disk. To convert all 15 disks from Differencing to Dynamic, I developed the following Powershell script:

# Script to convert Differencing Disk to Dynamic on all VMs on current host
# Sam Boutros
# 6/2/2014
# Convert-DiffDisk.ps1
# Needed after using PDT to create private cloud VMs – cannot live-migrate VMs with differencing disks
$Loc = Get-Location
$Archive = $Loc.Path + “\”
new-item $Archive -type directory -ErrorAction SilentlyContinue
$Date = Get-Date -format yyyyMMdd_hhmmsstt
$logfile = $Loc.path + “\Convert_” + $Date + “.txt”
function log($string, $color)
if ($Color -eq $null) {$color = “white”}
write-host $string -foregroundcolor $color # Sorry Don Jones 🙂
$temp = “: ” + $string
$string = Get-Date -format “yyyy.MM.dd hh:mm:ss tt”
$string += $temp
$string | out-file -Filepath $logfile -append
function Convert_Disk0($VM)
$Disk0 = Get-VMHardDiskDrive -VMName $VM -ControllerType IDE
$Source = $Disk0.Path
$Destination = $Source.Insert($Source.IndexOf(“.vhdx”,1),”_C1″)
log “Stopping $VM VM” green
Stop-VM -Name $VM
log “Converting disk $Source” green
Convert-VHD -DestinationPath $Destination -Path $Source -VHDType Dynamic
log “Attaching new disk $Destination to $VM” green
Get-VMHardDiskDrive -VMName $VM -ControllerType IDE | Set-VMHardDiskDrive -Path $Destination
log “Starting $VM VM” green
Start-VM -Name $VM
log “Moving old disk file $Source to $Archive folder” green
Move-Item $Source $Archive
$VMs = Get-VM -ComputerName $env:COMPUTERNAME
# To convert the IDE disk on all VMs on the current host use the following line:
# Foreach ($VM in $VMs.Name) { Convert_Disk0 $VM }
# To convert the IDE disk of a single VM use the following line – replace “VMM01” as needed:
Convert_Disk0 “VMM01”


2 responses

  1. Daniel

    An easier route would be to use separate disks in the first place. All you need is change the Variable.xml file in the VM configuration. Change the OSDisk Type section to ‘Copy’. Here is the section:




    June 3, 2014 at 9:51 am

    • Excellent, I see it on lines 237, 401. I remember seeing the disk type in the variable.xml as Differencing. My initial thought was to replace it with the disk type I wanted “Dynamic”, but I wasn’t sure how will the script interpret that..

      June 3, 2014 at 11:16 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.