Posts tagged “Differencing Disk


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”