pvandervelde / mindvortex

The source code for my personal website

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating a windows 2016 base image with Packer on Hyper-V

pvandervelde opened this issue · comments

Describe all the steps we took to make it work. And the steps taken to verify the base image too. This might be multiple posts.

Steps we are taking in the unattend:

  • Create disks. Because we are installing as Gen 2 VM (and thus UEFI) we need 3 disks (EFI, MSR and Primary)
  • OS image to install is either Windows 2016 DATACENTER or DATACENTERCORE
  • Set product key to be the AVMA key so that the final machine will be activated against the Hyper-V server (which is running on datacenter

Items to remember:

  • The windows 2016 ISO assumes manual installation, i.e. somebody is available to click buttons, and so it expects somebody to press a button to continue installation. That's not helpful for unattended installations. In order to fix this you need to unpack the ISO and change the cdboot.efi -> cdboot_prompt.efi and change efisys.bin to efisys_prompt.bin, and then rename the other versions of those files to cdboot.efi and efisys.bin. For more details see here: http://allandynes.com/2015/09/generation-2-hyperv-hosts-and-iso-files/ and here: https://blogs.technet.microsoft.com/jhoward/2013/11/11/hyper-v-generation-2-virtual-machines-part-9/
  • Using the hyperv-iso builder. This works quite well actually.
  • Packer doesn't handle sysprep -shutdown very well. Actually it doesn't handle it at all. So have to do all the work and then let packer force shut down the machine
  • Packer needs WinRM to be able to interact with the machine, however that doesn't deal with reboots (windows updates anybody) so have to do the updates before we enable WinRM. In the unattend file we can disable WinRM, and then enable after all the updates have been installed.
  • Windows updates are slow. Ideally we'd create a VHD and then bake most of the updates into the VHD before even starting the VM, but we can't do that with the current version of Packer