I believe in Hyper-V!

Windows Server 2012 R2Category Archives

Hyper-V did not find virtual machines to import from location “*”… migration from 2K8R2 to WS2012R2

As I said a few times so far, I have been writing blog posts to be my reminder and help to other blog readers :). Two days ago I migrate one of virtual machines from Windows Server 2008 R2 Hyper-V host to Windows Server 2012 R2 Hyper-V host. As many times until now I did Export then copy to the new storage and then Import, but… I forgot that I already did that a few months ago and what first need to do :). I got error like in the picture below ;)

1

This isn’t something new. I rewrite Rhoderick’s and Taylor’s articles. Thank you guys.

VM’s that are exported from Windows Server 2008 or 2008 R2 utilized the version 1 WMI namespace which resulted in a .exp file to represent the exported virtual machine. In Windows Server 2012 we introduced a new WMI namespace (version 2 or root\virtualization\v2) which implemented a much better import/export model – allowing you to effectively just copy the virtual machine folder (with the VM’s XML configuration file inside it) as well as the VM’s VHDs and then import that directly. For Windows Server 2012 we maintained the version 1 WMI namespace which allowed for importing of Windows Server 2008/R2 VM’s on 2012.

In Windows Server 2012 R2 we have removed the old version 1 namespace which means we can’t import virtual machines that where exported from Windows Server 2008/R2. However we can import them if you copy the virtual machine xml file and VHD’s – to do this you need to stop the vmms on the 2008/R2 server – copy all of the virtual machine files/vhds to the Windows Server 2012 R2 server and then import them.

What to do? We have two solutions!

The first is as follows:

Shut down all Hyper-V virtual machines on the WS2008R2 host then stop the Hyper-V Virtual Machine Management service.

1

net stop "Hyper-V Virtual Machine Management"

1

Copy all virtual machines what you want to migrate to WS2012R2 Hyper-V host then Import Virtual Machine… That’s easy way, but…

1

What if we already did Export and we don’t have WS2008R2 Hyper-V host?

The second resolution is as follows:

Exported Hyper-V virtual machines copy on the Windows Server 2012 and import them, then simple copy to a Windows Server 2012 R2. That server is only used to perform the import thus allowing the VM to be copied to Windows Server 2012 R2.

Now we can do whatever we want to do :)

I worked over the holidays and from tomorrow I’m going to deserved break until the end of the week.

Enjoy the day!

Romeo

Virtual disks under Storage Spaces won’t stay attached after reboot!

Few days ago friend of mine asked me if I know how to fix this issue and I succeeded. Now I want to share with all of you.
The scenario is as follows…

Windows Server 2012 R2, one Storage Pool, few virtual disks. The behavior starts to happen after Windows Server 2012 R2 re-installation. Everything was fine until restart. Virtual Disks are present and attached but after restart the server they are detached.

Before restart.10

After restart
10

If you are looking under virtual disk Properties/Details/Property (look picture below) you will notice that IsManualAttach – Value is True. In other words, if you want virtual disk be attached you must do manually attach.

10

Resolution

Open PowerShell as administrator, type as follows and press Enter

Set-virtualdisk -FriendlyName <VirtualDiskName> -IsManualAttach $false

10

Refresh Server Manager Console and you Virtual Disks will be attached. After you restart your server Virtual Disks still be attached ;)

10
10

I wish you all the best in 2014!

Enjoy the day :)

Cheers!

Romeo

Create HA virtual network for Hyper-V in Windows Server 2012 R2

In this blog post I’d like to explain how to create highly available virtual network for Hyper-V virtual machines as well as for Hyper-V hosts and other services related on virtual machines.
Not that log ago practice was; you have to have at least four network adapters on Hyper-V host. One for the management, one for the live migration, one for a backup, virtual machines etc. But! What if network adapter for management or for virtual machines corrupt? We don’t have access to hosts or virtual machines!
To avoid this we will be create highly available virtual network. I have one Hyper-V host with three physical network adapter! I’ll first rename physical adapters then I’ll create NIC Team, Virtual Switch and Virtual Network Adapters.

1. Rename physical NICs
10 10
Why we need to rename NICs? If one or more network adapters spoil you don’t know which one is broken. On this way we will exactly know which one and in which PCI bus port is spoiled. Look picture below.

10

Here is PowerShell script!

Function Resolve-PCIBusInfo { 

param ( 
[parameter(ValueFromPipeline=$true,Mandatory=$true)] 
[string] 
$locationInfo 
) 
PROCESS { 
[void]($locationInfo -match  "\d,\d,\d") 
$busId,$deviceID,$functionID = $matches[0] -split "," 

new-object psobject -property @{ 
          "BusID" = $busID; 
          "DeviceID" = "$deviceID" 
          "FunctionID" = "$functionID" 
          } 
}         
} 



Function Rename-NicBusFunction { 
$Adapters = get-wmiobject win32_networkadapter -filter "netenabled=true"  | where {$_.PNPDeviceID -notlike "ROOT\*"}
foreach ($Adapter in $Adapters ) {
    $AdapterName = Get-WMIObject Win32_NetworkAdapter | where { $_.PNPDeviceID -eq $Adapter.PNPDeviceID }
    $OldName = $AdapterName.NetConnectionID
    write-host "Network Adapter name before:" $OldName
    
        $DeviceID = $Adapter.PnPDeviceID 
        $locationInfo = (get-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Enum\$DeviceID" -name locationinformation).locationINformation 
        
        if ($locationInfo -match  "\d,\d,\d") {
            $BusInfo = Resolve-PCIBusInfo -locationInfo $locationinfo 

        $Bus = $BusInfo.BusID
        $Funct = $BusInfo.FunctionID 
        $NewName = "NIC-$Bus-$Funct"
        
        $AdapterName.NetConnectionID = "$newName"
        $rename = $AdapterName.Put()
        write-host "Network Adapter name after : $NewName"
        }
        else {
        $NewName = write-host "Network name not changed. Old name: $OldName"
        }
    Write-Host
}
}

Rename-NicBusFunction

The next step is to create NIC Team. We can do that on two ways, with GUI or with PowerShell. I prefer PowerShell

10

10

New-NetLbfoTeam -Name SMBTeam -TeamMembers NIC-2-0,NIC-3-0,NIC-4-0 -LoadBalancingAlgorithm Dynamic -TeamingMode SwitchIndependent

 

Now we have NIC Team called SMBTeam, Switch Independent, Dynamic crated from three physical network adapters.

In the next step we will create virtual switch. This kind of virtual switch we can create only with PowerShell. As you can notice I don’t have any virtual network switch created in Hyper-V.
10

So, let’s create one Converged Virtual Switch and four Virtual Network adapters.

10

This server will be Hyper-V Cluster node and I created four virtual network adapters. Heartbeat, LiveMigration, VmLan and one for Management. Now I have highly available virtual network. As you can see in the picture below, if I disable three of four virtual adapters or two of three physical adapter still can connect to Hyper-V host ;).

10

Cool, isn’t it ;)

 

Here you can find PowerShell script for Converged network.

New-NetLbfoTeam -Name SMBTeam -TeamMembers NIC-2-0,NIC-3-0,NIC-4-0 -LoadBalancingAlgorithm Dynamic -TeamingMode SwitchIndependent
New-VMSwitch -Name ConvergedHyperSwitch -NetAdapterName SMBTeam -AllowManagementOS $False -MinimumBandwidthMode Weight
Add-VMNetworkAdapter -ManagementOS -Name "Management" -SwitchName "ConvergedHyperSwitch"
Add-VMNetworkAdapter -ManagementOS -Name "VmLan" -SwitchName "ConvergedHyperSwitch"
Add-VMNetworkAdapter -ManagementOS -Name "LiveMigration" -SwitchName "ConvergedHyperSwitch"
Add-VMNetworkAdapter -ManagementOS -Name "Heartbeat" -SwitchName "ConvergedHyperSwitch"
Set-VMNetworkAdapter -ManagementOS -Name "Management" -MinimumBandwidthWeight 20
Set-VMNetworkAdapter -ManagementOS -Name "VmLan" -MinimumBandwidthWeight 20
Set-VMNetworkAdapter -ManagementOS -Name "LiveMigration" -MinimumBandwidthWeight 20
Set-VMNetworkAdapter -ManagementOS -Name "Heartbeat" -MinimumBandwidthWeight 20
New-NetIPAddress -InterfaceAlias "vEthernet (Management)" -IPAddress 192.168.0.130 -PrefixLength "24" -DefaultGateway 192.168.0.224 
Set-DnsClientServerAddress -InterfaceAlias "vEthernet (Management)" -ServerAddresses 192.168.0.203, 192.168.0.202 
New-NetIPAddress -InterfaceAlias "vEthernet (LiveMigration)" -IPAddress 192.168.30.30 -PrefixLength "24" 
New-NetIPAddress -InterfaceAlias "vEthernet (VmLan)" -IPAddress 192.168.28.30 -PrefixLength "24"
New-NetIPAddress -InterfaceAlias "vEthernet (Heartbeat)" -IPAddress 192.168.29.30 -PrefixLength "24"

 

In the next posts I’ll be write about Hyper-V Cluster, SMB Cluster, Storage Spaces and everything related on HA Hyper-V virtual machines.

P.S. Big thanks to my buddies Luka Manojlovič and Tomica Kaniški who helped me.

Stay tuned and be virtualized :)

Also, tomorrow is Christmas and I wish you all the best. Get rest and see you in 2014.

Cheers,

Romeo