Acknowledgement: I’d like to recognise John Howard’s TechNet Blog series about Gen2 VMs on Windows Hyper-V 2012 R2. Specifically two posts about conversion. Without these blogposts I wouldn’t have known where to start and this article wouldn’t have been possible. As far as I can tell there are no Microsoft KB articles on the topic, essentially because Microsoft doesn’t have a recognised process for converting Gen1 to Gen2.
In the world of VMware, when a big new shinny version of vSphere is released it’s not uncommon to find that a new version of VMware Tools and a new virtual hardware level is available. Since vSphere 5.1 it’s possible to upgrade VMware Tools without a reboot, albeit with caveats. Upgrades of the virtual hardware aren’t mandatory – but you do need to power off the VM before editing the virtual machines settings. The nice thing about the upgrade of virtual hardware is the total absence of a torque screwdriver (that’s my little joke by the way).
Note: As we all know upgrading the virtual hardware exposes a new hardware level (which we now refer to as a “compatibility level” which is a combination of VMware Tools version and hardware level) with new features. In the case of hardware level 8 this includes 32-vCPU, 1TB RAM, 3D Graphics for Aero, USB 3.0 and UEFI virtual BIOS. The nice thing about the VMware method is we can defer the upgrade until the next normal guest OS shutdown – or “Patch Tuesday” as its known in the trade. 🙂
In case you don’t know Windows Server 2012 Hyper-V R2 introduced a new Gen2 VM definition. It supports UEFI, boot from SCSI devices rather than IDE, and removes some (but not all) legacy devices in their VM. Perhaps the biggest reason to use a Gen2 over Gen1 VM is the ability to resize disks on the boot disk – something an IDE/Gen1 was incapable of doing. Personally, I find all this quite bizzare. VMware vSphere VMs have always been able to boot from SCSI, and hot-extend of disks from the command-line and UI were added donkey’s years ago…
Sadly, our friends over on the Microsoft side of the fence don’t have it so easy when it comes to “upgrading” from Gen1 virtual machines, to Gen2 virtual machines – that were introduce mid-way in the life of Windows Server 2012 Hyper-V R2. The process (and I’m being generous by using that term) involves many, many steps if you are doing it manually using four different command-line tools, and many different PowerShell cmdlets. True, there is PowerShell script that “automates” some of this – but the critical bottleneck has to do with copying of the contents of the Gen1 VHD disk into a Gen2 VHDX disk – something Powershell cannot improve. This conversion has to happen because Gen1 VMs were IDE based, and Gen2 are SCSI based – and Gen2 VMs do not support booting from IDE. From a performance perspective I don’t see how SCSI would be any better than IDE. It’s virtual after all – but it does show what a pain in the rear only supporting IDE has become. Even when given a blank slate to begin with, Microsoft made a poor decision back in their first iterations of virtualization.
So not only do you have to claim a maintenance window to carry out the process – the time the “conversion” takes is directly related to the speed of your storage and volume of data inside the virtual disk. The other thing to be careful with is – as this process uses “diskpart” you could easily repartition the wrong disk – so be cautious as this runs the risk of data lost. The last thing you want to be doing is reaching for your backup catalog whilst attempting a conversion. As with all Microsoft conversions/upgrade paths the story gets decidedly shaggier the more you get into the process… For instance even after doing the disk conversion – a new Gen2 VM has to be created, so any “custom” settings you had on the Ye Olde Gen1 VM will need documenting and configuring on the new VM… L With that said Howard’s script does handle this more efficiently.
Having worked through the manual process and the Powershell script, and considering the fact that this involves data crunching and extended maintenance windows – it’s my bet most Windows Hyper-V customers wouldn’t want to undertake this “conversion” process. Instead they would probably run with their existing Gen1 where possible, and adopt a policy that all new VMs based on Windows Hyper-V 2012 R2 would be Gen2 based. Another approach would be to invest in some 3rd party tools to help in the conversion. This is all rather ironic to me. Folks who adopt Windows Hyper-V often bang on about cost savings – and they are unlikely to want to supplement entry-level virtualization with additional software. A case of pennywise and pound foolish, perhaps?
Sadly, I think that this Gen1 to Gen2 pain point diminishes the impact of the new Gen2 feature in the short-term… Of course you could always just reinstall Windows to a clean VM, and not bother with this conversion process. We have been here before in my previous article “What works best – Clean install or upgrade”. That’s a view echoed in John Howards post at the end of the process:
So that’s it. Although somewhat involved, that is what it takes to convert a workload from generation 1 to generation 2. You may, of course, decide that a clean installation may be simpler.
Okay. Deep breath. I’ve broken this down into 8 main steps – the truth is within these 8 steps are quite a few sub-steps. Remember the fastest way of doing this is to use the MSDN available PowerCLI script. I’m going try both methods to see how they fair. I think it’s important to know the manual process prior to automation in case the train comes off the tracks.
- Disable the recovery environment in source VM
- Shutdown source VM; Mount VHD; Capture the image
- Create a new VHDX
- Partition in the GPT format
- Clone WIM to VHDX; Configure BCD Store
- Clean up and Unmount VHD/VHDX files
- Attached to new Gen2 VM
- Rebuild recovery partition and re-enable recovery environment
Of course – they’re some important caveats around this process to be aware off:
- By cloning a Gen1 VM to be Gen2 VM – you have two copies of the same VM. You should only power one on at any time to prevent IP conflicts, and potential AD issues associated with computer accounts – or patch them into different networks or VLANs
- Even if you use the script – parts 1 and 8 must be done before hand
My tests were done using a Windows 2008 R2 instance running IIS. And this was my first mistake. I didn’t check to see what OS types are supported with the new Gen2 format. I just assumed Microsoft would support Windows 2008 R2 because it’s still so popular in customer environments. It turns out Gen2 VMs can only use Windows 2012 or Windows 8.