Install Windows via VNC KVM on a VPS using GRUB

Downloads

Windows Server 2016 trial iso
https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO

or

http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SSS_X64FREE_EN-US_DV9.ISO

virtIO Drivers (windows x64)
stable-virtio/virtio-win.iso

ADK for new version of DISM
https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install

Requirements

A VPS with KVM via VNC or similar, not OpenVZ.

If you require virtio drivers (often the case) you also need a Windows Machine to modify boot.wim for adding the drivers.

References

A working GRUB entry for Windows Installer by Will Haley

menuentry "Windows 10 Installer" {
insmod ntfs
search --set=root --file /bootmgr
ntldr /bootmgr
boot
}

How to add virtio drivers to Windows Installer with DISM on Windows (in case you need it)

  1. Install ADK from Download link above (for new version of DISM)
  2. Download the Windows ISO
  3. Mount or extract the ISO to copy boot.wim from /sources/boot.wim to your preferred working directory
  4. Create a folder where you will mount boot.wim, eg C:/mount
  5. Open CMD with Administrator Privileges
  6. Mount the boot.wim with DISM /mount-image /imagefile:/path/to/boot.wim /index:2 /mountdir:C:/mount
  7. Put the folder with your drivers into C:/mount/sources/<your folder>
  8. Unmount boot.wim and commit changes with DISM /unmount-image /mountdir:C:/mount /commit
  9. Where ever you put your boot.wim before mounting has now been modified with your changes

Steps on your target system

  1. (optional) Install some linux operating system with grub (eg. Debian)
  2. or create a grub partition with grub-install from a live boot or rescue mode
Creating the Windows Installer Partition
  1. Boot into a rescue system or live boot (eg. SystemRescueCd or Debian Live)
  2. Change your partitions to make about 8 GB free space for a new NTFS partition which will be the Windows Installer (eg. gparted or fdisk)
  1. Set a “boot” flag on your new 8 GB NTFS partition
  2. In case you don’t know already, type lsblk to show your partitions and locate your new 8 GB partition. Mine is called /dev/sda3
  3. mkfs.ntfs /dev/sda3 (maybe use –quick option)
Transfer Windows ISO and boot.wim

Note: Instead of doing these steps you could also just upload the ISO contents directly to your 8GB NTFS partition including the modified boot.wim which goes here: /sources/boot.wim

  1. Leave rescue and boot back into Debian
  2. Put your modified boot.wim and Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO in /root.
  3. apt-get install ntfs-3g -y
  4. Mount your 8 GB ntfs partition mkdir /mnt/winboot && mount -t ntfs-3g /dev/sda3 /mnt/winboot
  5. Wait until the Windows iso is fully transferred then do mkdir /mnt/winiso && mount -o loop /root/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO /mnt/winiso
  6. Copy the Windows iso contents to your 8 GB partition with cp -rv /mnt/winiso/* /mnt/winboot
  7. Replace boot.wim cp /root/boot.wim /mnt/winboot/sources/boot.wim confirm overwrite if required
Adding Windows Installer to GRUB2
  1. (optional) Type os-prober you should see something like this /dev/sda3:Windows Recovery Environment (loader):Windows:chain
  2. Edit /boot/grub/grub.cfg and add snippet references above, might need to mount your grub partition first.
  3. or enter the commands referenced above directly into grub rescue

Hint: If Windows 2016 Installer fails with System Thread Exception try Windows 2012 instead.