NOTE:

We do not have any Windows licence or Windows distribution available for you. You will need to have these yourself.

Create a VM with Microsoft Windows

In order to run Windows on a VM, you will need to proceed with the full installation as if it would be a local physical machine (e.g.: your laptop). But then, with the extra overhead of making the necessary adjustments so that your VM will work in the virtual environment that the HPC Cloud offers. These are the steps that we will carry out to make it work:

  1. Prepare the installation
  2. Run the Windows installation
  3. Configure contextualization
  4. Prepare your VM for production

Let us look into these steps with more detail.

Prepare the installation

NOTE:

Make sure you have your Windows ISO available in your laptop, so that you can upload it to the HPC Cloud.

In this section we will be setting up the environment within your project (or Group) space in the HPC Cloud. It involves:

  1. Creating an image that will be empty in the beginning, which will work as an empty hard drive where you will install Windows
  2. Creating an image with the Windows installation media, by uploading your Windows ISO
  3. Creating an image with the Virtio drivers for Windows, by fetching an ISO from the Internet
  4. Creating a couple of files on the UI by downloading them from the Internet and uploading them to the UI
  5. Creating a template where you bring all these components together, which you can use to start a VM from

Creating the destination hard drive

Analogously to your laptop, your VM needs a hard drive where the operating system can be installed and where it will live. We will create one here.

  1. On the UI: Go to the Images tab (under Storage), and click on the green [+] button (on the top-left corner of the screen) to start creating a new image. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in a meaningful Name (e.g.: windows_drive, we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type DATABLOCK
    • leave Datastore with 104: local_images_ssd
    • check the This image is persistent checkbox
    • on the Image location: group, choose radio button Empty disk image
    • and give it a Size that is meaningful to you (e.g.: our test with installing Windows 8.1 required already 10GB for Windows alone, so we filled in 20GB)
  3. On the UI: Click the green button Create on the form, to submit it. A new image will show on the Images list, and it will keep in status LOCKED while it is being created. When it is created it will come to status READY.

Uploading the Windows ISO

  1. On the UI: On the Images tab (under Storage), click on the green [+] button (on the top-left corner of the screen) to start creating a new image. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in a meaningful Name (e.g.: windows_iso, we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type Readonly CD-ROM
    • leave Datastore with 104: local_images_ssd
    • leave the Persistent checkbox unchecked
    • on the Image location: group, choose radio button Upload; then, underneath, click on Choose file to have a dialogue pop up where you will look for the path on your laptop where you have your Windows .iso file and, finally, choose the .iso file to close the pop-up dialogue to return to the original form
  3. On the UI: Click the green button Create on the form, to submit it. A progress bar will show at the bottom of the screen, which will advance as the upload of your .iso file evolves. When the upload is complete, a new image will show on the Images list, and it will keep in status LOCKED while it is being created. When it is created it will come to status READY.

Fetching the Virtio drivers

The best way to make physical hardware (namely: hard drives and network adapters) available to VMs in the HPC Cloud is by using Virtio drivers. However, Windows does not natively support those drivers, but if we make them available to the Windows installer, we will have no problem using them. This requires making them available externally, and that is what we will do in this step.

  1. On the UI: On the Images tab (under Storage), click on the green [+] button (on the top-left corner of the screen) to start creating a new image. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in a meaningful Name (e.g.: virtio_drivers_iso, we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type Readonly CD-ROM
    • leave Datastore with 104: local_images_ssd
    • leave the Persistent checkbox unchecked
    • on the Image location: group, choose radio button Path in OpenNebula server; then, underneath, type the following URL in the Path field: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
  3. On the UI: Click the green button Create on the form, to submit it. A new image will show on the Images list, and it will keep in status LOCKED while data is being downloaded from the URL you wrote. When it is created it will come to status READY.

Fetching the contextualization files

NOTE:

You can read more about Windows contextualization for OpenNebula here:

On the HPC Cloud, VMs use the contextualization mechanism to configure themselves. In particular, you will need to have 2 files on your VM so that it can actually configure itself. We will be making those available in this step so that, at a later step, we can make your VM use them.

  1. On the UI: On the Files tab (under Storage), click on the green [+] button (on the top-left corner of the screen) to start creating a new file. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in Name: context.ps1 (we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type CONTEXT
    • leave Datastore with 105: local_files_ssd
    • on the Image location: group, choose radio button Path in OpenNebula server; then, underneath, type the following URL in the Path field: https://raw.githubusercontent.com/OpenNebula/addon-context-windows/master/context.ps1
  3. On the UI: Click the green button Create on the form, to submit it. A new file will show on the Files list, and it will keep in status LOCKED while data is being downloaded from the URL you wrote. When it is created it will come to status READY.

Now, the other file:

  1. On the UI: On the Files tab (under Storage), click on the green [+] button (on the top-left corner of the screen) to start creating a new file. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in a meaningful Name (e.g.: startup.vbs, we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type CONTEXT
    • leave Datastore with 105: local_files_ssd
    • on the Image location: group, choose radio button Path in OpenNebula server; then, underneath, type the following URL in the Path field: https://raw.githubusercontent.com/OpenNebula/addon-context-windows/master/startup.vbs
  3. On the UI: Click the green button Create on the form, to submit it. A new file will show on the Files list, and it will keep in status LOCKED while data is being downloaded from the URL you wrote. When it is created it will come to status READY.

If we leave it here, then you VM will be configured only once ever. If you want the VM to be reconfigured every time it boots, then you need to delete a flag file that prevents contextualisation from happening ever again. We have added a script that will delete this file for you every time Windows shuts down or reboots. Here is how you add it:

  1. On the UI: On the Files tab (under Storage), click on the green [+] button (on the top-left corner of the screen) to start creating a new file. A form will pop up.
  2. On the UI: On the form that popped up:
    • type in a meaningful Name (e.g.: shutdown.vbs, we will use this name later)
    • type in a meaningful Description (optional)
    • choose Type CONTEXT
    • leave Datastore with 105: local_files_ssd
    • on the Image location: group, choose radio button Path in OpenNebula server; then, underneath, type the following URL in the Path field: https://raw.githubusercontent.com/sara-nl/clouddocs/gh-pages/assets/shutdown.vbs
  3. On the UI: Click the green button Create on the form, to submit it. A new file will show on the Files list, and it will keep in status LOCKED while data is being downloaded from the URL you wrote. When it is created it will come to status READY.

Create a template

Now that we have all components ready in the UI, we are ready to bring them together. On the HPC Cloud, we do that on a template.

  1. On the UI: On the VMs tab (under Templates), click on the green [+] button (on the top-left corner of the screen) to start creating a new template. The page will change into the Create VM Template screen.
  2. On the UI: On the Create VM Template screen, on the General tab:
    • type in a meaningful Name (e.g.: windows_setup, we will use this name later)
    • type in a meaningful Description (optional)
    • choose a Logo that you like
    • type in (or use arrows) 8GB of Memory
    • type in (or use arrows) 1 CPU
  3. On the UI: On the same Create VM Template screen, on the Storage tab:
    • for the Disk 0 (on the left column of the screen), choose the windows_drive image (from the table on the right of the screen) that you created as the first image of this guide
    • click on the + Add another disk button (that will make a new Disk 1), and then choose the windows_iso image you created as a second image of this guide
    • click again on the + Add another disk button (to make a new Disk 2), and then choose the virtio_drivers_iso image
  4. On the UI: On the same Create VM Template screen, on the Network tab:
    • for the Interface 0 (on the left column of the screen), choose the internet network (from the table on the right of the screen)
    • click on the + Add another nic button (that will make a new Interface 1), and then choose your internal network (it will be the only other network that you can see on the right that is not called internet)
  5. On the UI: On the same Create VM Template screen, on the OS Booting tab:
    • for the 1st Boot field, choose CDROM
    • for the 2nd Boot field, choose HD
  6. On the UI: On the same Create Template screen, on the Input/Output tab:
    • click on the VNC radio button
    • on the Inputs group, choose Tablet on the first dropdown menu, then USB on the second dropdown menu and finally click on the Add button. A new entry will appear below those dropdowns with what you just selected.
  7. On the UI: On the same Create VM Template screen, on the Context tab:
    • click on Files on the left column of the screen
    • make sure you select the files you created before; those are: context.ps1, startup.vbs and shutdown.vbs
  8. On the UI: We are ready defining the template, so click on the green Create button at the top of the screen. A new template will show on the Templates list.

Run the Windows installation

We will now create a VM and run the Windows installation on it.

  1. On the UI: Go to the VMs tab (under Instances). Click on the green [+] button (on the top-left corner of the screen) to start creating a new VM. The page will change into the Create Virtual Machine screen.
  2. On the UI: On the Create Virtual Machine screen:
    • choose the template you defined before (i.e.: windows_setup)
    • type in a meaningful VM Name (e.g.: windows_first)
  3. On the UI: We are ready defining the VM, so click on the green Create button at the top of the form. A new VM will show on the Virtual Machines list. It will go through several states (e.g.: PENDING, PROLOG…) until it reaches the RUNNING state. Notice that to reach this state it can take a few minutes (circa 3’ for current setup).
  4. On the UI: You can then start operating within your VM. Click on the screen-like button that you can see to the right of your VM on the list. It will pop-up the VNC console, so you should be able to see the welcome screen of your Windows installation.

Now you need to install Windows with custom installation, by following the steps you would normally follow. Only, with one caveat: you need to install the Virtio drivers, as pointed out before.

Installing the Virtio drivers

While running the Windows installer, you will reach a step in which you have to choose which disk (or drive) to install Windows on. It will be empty, because the disks are made available to your VM via Virtio, but you have not installed the Virtio drivers yet so your Windows installation cannot see the disk. This is how you do it:

  1. On the Windows VM: At the step where you need to choose a disk on which to install Windows, click on the Load driver button (under the big white empty area). A dialogue pops up.
  2. On the Windows VM: On the pop-up dialogue, click on the Browse… button. A Browse for folder tree will pop-up now.
  3. On the Windows VM: We will start with the network interfaces driver. On the chooser tree, you will see two entries that represent two CD-ROM drives. Click on the one that holds the Virtio drivers (therefore, not the one labeled CONTEXT), and open folder NetKVM, then the folder that matches your Windows version, and then the 64-bit or 32-bit version depending on your Windows as well.
  4. On the Windows VM: After you chose the folder, a pop up will show the drivers that it could locate (or click on Scan to refresh the list). Doubleclick the only entry that you should see, so that it is installed.
  5. On the Windows VM: Now we will repeat the process for the disks driver. On the chooser tree, you will see two entries that represent two CD-ROM drives. Click again on the one that holds the Virtio drivers (therefore, not the one labeled CONTEXT), and open folder called viostor, then the folder that matches your Windows version, and then the 64-bit or 32-bit version depending on your Windows as well.
  6. On the Windows VM: Again, on the next screen, click on Scan if the list of detected drivers is not updated. Then install the driver. At this point, the originally white area shows one entry: your disk.
  7. On the Windows VM: You can finally click on the drive to get Windows installed on it.

You can continue with the rest of the Windows installation process normally. Then, reboot so that your newly installed Windows starts up (make sure you do not start the installation again).

Configure contextualization

Once your freshly installed Windows starts, we will configure your VM so that it auto-configures itself on start up (e.g.: at this point, you can see that there is no active network connection, so you cannot even browse the web).

  1. On the Windows VM: Open the file explorer, and browse the CONTEXT CD-ROM. You should be able to see at least 4 files on that CD-ROM. Three of them should be the ones we manually added to the Context tab of the template some steps ago, called: context.ps1, startup.vbs and shutdown.vbs.
  2. On the Windows VM: From the CONTEXT CD-ROM, copy the 3 files context.ps1, startup.vbs and shutdown.vbs to the C:\ drive. They will thus become reachable at C:\context.ps1, C:\startup.vbs and C:\shutdown.vbs.
  3. On the Windows VM: We must configure the C:\startup.vbs file as a start-up script, so that Windows runs it automatically upon booting. We must also configure the C:\shutdown.vbs file as a shutdown script, so that Windows runs it automatically upon shutting down. To do all of this, start by right-clicking on the Windows Start button, and then choose option Run. A dialogue will pop up.
  4. On the Windows VM: On the dialogue that just popped up, type the following in the Open: field: gpedit.msc. A new window titled Local Group Policy Editor will show.
  5. On the Windows VM: On the Local Group Policy Editor, navigate to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown). Then doubleclick on Startup. A new Startup Properties dialogue will pop up.
  6. On the Windows VM: On the Startup Properties dialogue, click on the Add button. A new Add a Script dialogue will pop up.
  7. On the Windows VM: On the Add a Script dialogue, click on the Browse… button, and look there for the C:\startup.vbs file. A new entry will appear on the Startup Properties dialogue indicating that you have added the new startup script. Click OK, then Apply and then OK again, to return to the Scripts (Startup/Shutdown) window.
  8. On the Windows VM: You can reboot your Windows now. When it boots up, and (probably) after a while after you log in, your network adapters will stop showing the yellow warning icon and you should be able to browse the Internet now.
  9. On the Windows VM: We will now tackle the shutdown script. Doubleclick on Shutdown. A new Shutdown Properties dialogue will pop up.
  10. On the Windows VM: On the Shutdown Properties dialogue, click on the Add button. A new Add a Script dialogue will pop up.
  11. On the Windows VM: On the Add a Script dialogue, click on the Browse… button, and look there for the C:\shutdown.vbs file. A new entry will appear on the Shutdown Properties dialogue indicating that you have added the new shutdown script. Click OK and Apply.
  12. On the Windows VM: You can reboot your Windows again. Make sure you have internet again.
  13. On the UI: You can now shut your VM down. Notice that OpenNebula will take some minutes to gracefuly shutdown the VM, similar time than when the VM was instantiated.

We will proceed now with the removal of all the installation media and prepare your VM for production.

Prepare the VM for production

Once you have installed and configured your Windows, you do not need the installation media or files around any more. We will make a new template to use only the disk that we need.

  1. On the UI: Begin creating a new template the usual way.
  2. On the UI: On the Create VM Template screen, on the General tab:
    • type in a meaningful Name (e.g.: my_research_run)
    • give it as much memory and as many CPU’s as you need
  3. On the UI: On the same Create VM Template screen, on the Storage tab:
    • for the Disk 0 (on the left column of the screen), choose the windows_drive image (from the table on the right of the screen) that you created as the first image of this guide, and where you have installed Windows
  4. On the UI: On the same Create VM Template screen, on the Network tab:
    • for the Interface 0 (on the left column of the screen), choose the internet network (from the table on the right of the screen)
    • click on the + Add another nic button (that will make a new Interface 1), and then choose your internal network (it will be the only other network that you can see on the right that is not called internet)
  5. On the UI: On the same Create VM Template screen, on the Input/Output tab:
    • click on the VNC radio button
    • on the Inputs group, choose Tablet on the first dropdown menu, then USB on the second dropdown menu and finally click on the Add button. A new entry will appear below those dropdowns with what you just selected.
  6. On the UI: On the same Create VM Template screen, on the Other tab, you want to tell Windows how to use multiple cores:
    • within the RAW data group, choose for the Type dropdown menu kvm, then in the DATA textfield to the right of it, write <cpu><topology sockets='1' cores='4' threads='1'/></cpu> (you should replace the cores number with the amount of them you need).
  7. On the UI: We are ready defining the template, so click on the green Create button at the top of the screen. A new template will show on the VM Templates list.

From now on, you will use this template to run your VM.


In the RAW data group, you must make sure that the <topology> that you set up there matches the cpu value that you set in the template. Otherwise, your VM will fail to launch!

Thus, make sure that: sockets × cores × threads = cpu

Enable Remote Desktop

Having to connect to the VM via the VNC console on the web UI is somewhat tedious and rather limited, so you probably want to access your VM via Remote Desktop. Here is how you can do that:

  1. In your local network: Make sure your firewall (maybe in your home router) has port 3389 open for your laptop.
  2. On the Windows VM: Right-click on the Windows Start button, and then choose option Run. A dialogue will pop up.
  3. On the Windows VM: On the dialogue that just popped up, type the following in the Open: field: gpedit.msc. A new window titled Local Group Policy Editor will show.
  4. On the Windows VM: On the Local Group Policy Editor, navigate to Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Security.
  5. On the Windows VM: Change the following two settings (doubleclick on each of them):
    • Require use of specific security layer for remote (RDP) connections from Not configured to Enabled, and then choose on the dropdown Security Layer, the value RDP.
    • Require user authentication for remote connections by using Network Level Authentications from Not configured to Disabled.
  6. On the Windows VM: Restart your Windows.

You should now be able to connect to your VM using a Remote Desktop client.


Appendix: Alternative CPU topology configuration

In the Prepare your VM for production section, we wrote a way to configure your VM so that Windows will understand what to do with the cores the VM has available. However, some users have reported that the following helped them instead:

<vcpu placement='static'>4</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='1'/>
<vcpupin vcpu='1' cpuset='2'/>
<vcpupin vcpu='2' cpuset='3'/>
<vcpupin vcpu='3' cpuset='4'/>
</cputune>
<cpu mode='host-passthrough'>
<topology sockets='1' cores='4' threads='1'/>
</cpu>

NOTE:

Some users report suffering from very unstable (to the point of unuseable) systems with Windows 7 running on more than 16 cores.

Appendix: Some Windows installation screenshots

windows01 windows02 windows03 windows04 windows05 windows06 windows07