Migrate XenServer VMs to HyperV

I recently had the unenviable task of moving a few XenServer based Virtual machines across to Hyper-V. Not the simplest of all tasks and disturbingly complex compared to the simplicity of moving VM’s in and out of vSphere. The tools are limited, and whilst there are some freebie options around to help, it’s the process rather than the tooling that is the challenge.

Below is what (after many attempts and head meets wall moments) I found to be the best way of consistently moving the workload from XenServer 7.6 to Hyper-V 2016. The VM’s in question are Windows Server 2016

Step 1. Uninstall XenServer Tools/Management Agent.

Snapshot your server.

These suckers go deep on the VM. I needed to remove these on the source VM to start with which is a commonly known requirement in the XenServer world. I came across some odd behaviours where even when removing the agent from add/remove programs, the driver sets would stay in play (confirmed under device management). To resolve, I had to reinstall the latest management agent, and then uninstall. This then left me with plenty of ghost devices to deal with

ManagementToolsOperational
Operational Management Tools
UninstallManagementTools
Uninstall Management Agents

I allowed the reboot despite some posts online saying to ignore it

ManagementToolsGone
No more tools

Step 2. Remove Ghost Devices

Anyone who has dealt with virtualisation and migrations of workloads will understand the concept of Ghost devices. Unfortunately removing the XenServer Management Agent does nothing to clean up its drivers or ghost devices, so you will need to do this manually. Luckily, Trentent Tye posted a nice PowerShell Script here to make your life easier

I would suggest checking device manager first and make sure that all XenServer based devices are 100% marked as Ghost (greyed out)

set devmgr_show_nonpresent_devices=1
start devmgmt.msc

DevMgmtGhosts
Ghost Devices via Device Manager

Now run RemoveGhosts.ps1 to clean out the Ghosts

RemoveGhosts
RemoveGhosts.ps1

Note below is a large list of Ghosts that have been removed

RemovedGhosts
Removed Ghost Devices

Step 3. Remove drivers from source VM

There are a few drivers that are deployed into the c:\windows\system32\drivers folder on your virtual machine. I needed to remove these manually before doing any conversion work

c:\windows\system32\drivers\

Get-ChildItem | ?{$_.Name -like “xen*”}

RemoveDrivers
Delete the Driver Files

Reboot your system

Step 4. Convert the VM

I chose to use Disk2Vhd from sysinternals for this part of the process, you can realistically do whatever you like tool wise, I like Disk2Vhd as its never ever failed me. Be warned, you will be using a stock standard legacy NIC without XenServer tools, so your transfer speeds will suck. You could alternatively choose to do a vm export via XenServer CLI at this point, but I didn’t test this (Thanks Tobias Kreidl for the pointer)

disk2vhd * c:\vhd\snapshot.vhd

Disk2VHD
Disk2VHD in action

Step 5. Check the VHDX

This part was pretty critical on a couple of my VM’s. After successfully converting the existing VM to a VHDX file, I mounted it to double check the drivers directory and make sure none of the Xen* drivers were still around, there were machines that managed to have these drivers in tact which would prevent the machines booting in Hyper-V.

You can also run defrags etc at this point, nice and easy whilst the VHDX is mounted

Step 6. Move on in life

It should now be a simple job of creating a new Hyper-V VM, pointing It to your converted VHDX file and powering on

MachineBoot
Happy HyperV Machine

Gotchas

  • I had some issues where the machine would blue screen on boot once converted – sure enough, those drivers we deleted off the image prior to imaging were back, most probably due to a reboot somewhere in the mix which would inject them back in
  • It is slow to convert across the wire when you don’t have XenServer Tools enabled, if you are doing this in bulk, an export at the XenServer layer may be far more efficient. I had sub 10 machines so manual was fine
  • If your Windows Server has issues with activation, I had no success in converting. The machines had to be activated and healthy with no pending installations for the conversion to successfully take

Summary

Hopefully this helps those that get stuck in migrating from XenServer to Hyper-V, as someone who has done extensive migration work across P2V and V2V over the years, this simple conversion task was one of the more frustrating ones with a few gotchas. Bring on vSphere converter I say

7 thoughts on “Migrate XenServer VMs to HyperV

Add yours

  1. I am currently thinking of setting up my first server at home and I am stuck (amongst other things…) at choosing between Hyper-V Server and XCP-NG for virtualizing it.
    I have to consider a lot of things to take a decision, but my understanding so far is that:

    1) Hyper-V is more focused on big enterprise applications and security, but the tooling is not the best (Windows Admin Center is quite good to manage Hyper-V but is lacking features, RSAT works but there are so many tools involved when it comes to managing Hyper-V that it feels like a complete mess, powershell is an option but it does not provide a good overview of the system as a web UI with graphs on it). Generally, I love WAC, powershell (somewhat…), the ability to connect to VMs using a “Remote Desktop Connection” that provides a reasonable screen resolution, the Virtual Switches concept, etc. But I found that backing up machines and monitoring them (and sending mail notifications based on events) is not so easy as with Xen Orchestra and XenCenter.

    2) XCP-NG has a ton of features. I love the backup options where you can schedule backups using Xen Orchestra (it requires quite some fuss to do the same on Hyper-V as far as I know) and the general plethora of options in the Xen Orchestra UI. But I found that the management tools (e.g. Xen Orchestra) are not so perfect at UX and security (web session cookies are not secured properly, no host/guest VM secure boot options, errors often leave the machines at invalid state and the GUI confused about it, etc). Who knows what happens in the hypervisor itself…

    I like the security and reliability of Hyper-V (which is backed by MS), but I also like the shiny features you get from XCP-NG out of the box.

    And I am really new to servers and virtualization, so I would hate having to go through the steps of this article, in order to migrate VMs from one to the other after a while.

    If you have any points that I have missed and want to share, so that I can decide based on more information, let me know.
    I am more interested at free solutions, low power consumption (Windows Defender on the Hyper-V management VM might cause problems there…), and things that work without much great effort on setup or maintenance.
    I have found “Veeam ONE”, which seems to have a free solution for monitoring Hyper-V, but I am not sure how good it is.
    I am sure there are paid solutions for Hyper-V that make backups easy, but I am low on budget.

    Thanks in advance for any reply, but don’t feel obliged to reply either. 🙂
    I am sure you have better things to do. 😉
    I just thought to post this question here, since you seem to know both of these hypervisors.

    Like

    1. There are ups and downs with all of them, I have mixed and moved depending on what I am wanting to play with or learn at the time, and sometimes you can even nest hypervisors within others to see the basics.

      Maybe for your situation vmware esxi (free) would be a great starting point – its management is great, there are plenty of free solutions to support it (Veeam community etc) and if you are new to it all then vSphere is a great place to start

      Like

      1. Thanks for the reply.
        I have some doubts for the free ESXi, because it is considered by some to be suitable only for test or low-risk environments:
        https://www.vladan.fr/esxi-5-free-whats-the-limitations/
        https://www.vladan.fr/esxi-free-vs-paid/

        Of course, I could hack my way around the limitations, but I am not afraid of managing Hyper-V via the command-line, so I am thinking of going towards that direction for now. There is also the “Windows Admin Center”, that is somewhat nice for managing the VMs in Hyper-V.

        Like

      2. Esxi is the exact same hypervisor you would use in enterprise – it just doesn’t have all the features enabled and turned on. HyperV is a perfectly good choice

        Like

      1. The procedure does work on Win 10. I tried the disk2vhd, but the transfer of the file without the drivers installed was quite painful. I ended up using the Export feature and a 3rd party tool (starwind) to convert them to vhdx files. I ran into the issue where the files would not delete and caused the matching to blue screen. Rolled back to the snapshot, uninstall Xen tools, reinstalled, uninstall, then all of the driver files removed and it is currently exporting.

        Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: