At the office, we have a server where the hyper-visor is 2012. It has a couple of VM’s running and this is stand alone. We want to upgrade it to 2012 R2 and just for fun did not wanted to shout down the VM’s to make an in-place upgrade. Just for fun, I wanted to simulate to be a production environments where VM’s down-time is to be avoided.
I asked a Stefan (a great college) to prepare a temporary server, which he did. This came set up with Hyper-V so I set the live migration setting and was good to go. Went to move the first VM and the wizard told me that the Ethernet switch “Intel(R) I350 Gigabit Network Connection – Virtual Switch” does not exist on the temporary server. In fact the switch was names simple “LAN”. I thought it’s easier to rename the switch “LAN” on the source then “Intel(R) I350 Gigabit Network Connection – Virtual Switch” on the destination – it involves less typing!!
On the source I’ve changed the switch name, checked the properties of a few VM’s and it was showing that they were connected to the “LAN” switch. Awesome, I can start the Shared Nothing Live Migration.
I’ve right click a VM and started the Move wizard. Then got an error that the Switch “Intel(R) I350 Gigabit Network Connection – Virtual Switch” does not exist on the destination. Luckily the wizard lets you choose an Ethernet Switch on the source and makes the move.
But then, I still had another 7 VM’s to move and did not wanted to do them one by one. The wizard only allows to move the VM’s one by one. A quick search and I found this great blog – http://blogs.technet.com/b/keithmayer/archive/2012/10/04/31days_2d00_winserv_2d00_livemigration.aspx by Keith Mayer
The idea of a single line PowerShell code which will queue all the VM’s to move one-by-one was good enough for me. In his blog Keith expands this to let you make the migrations simultaneously, so I suggest reading his post.
But the PowerShell code did not work, simply because, like the wizard, Hyper-V was still internally referring to the switch with VM’s are connected to on the source with the old name then with the new name. Even restart on the source (which defeated the scope of moving the VM’s without downtime) did not solve this.
The way to solve is to go on the settings of the VM’s one by one and change the Virtual Switch of the Lan adaptor. You have to change it to another switch (or Not Connected), apply and then back to the correct switch. Save and repeat on another VM till you do them all.
After re-setting the Virtual Switch to “LAN” on each VM, the PowerShell code worked like a charm.