How to Build an Image for Windows Virtual Machines

Solution Verified in:

  • OpenNebula: 5.10


This step-by-step tutorial will help users to build a Windows 10 Image to be used within an OpenNebula cloud to create KVM-based Windows Virtual Machines.


Practical Tip

The solution offered by this article is based on the CLI, but if want to know how to perform this task by using only OpenNebula's WebUI—Sunstone—have a look at the following screencast: 


Step 1: OpenNebula Installation

To setup quickly an OpenNebula environment we will use miniONE, an easy-to-use tool for deploying an evaluation OpenNebula cloud based on either KVM virtual machines or LXD system containers.

To setup a KVM-based environment (OpenNebula frontend plus a KVM hypervisor node) you need a physical host (x86-64 Intel or AMD processor) with virtualization capabilities and with one of these supported Operating Systems.

Then you can run the following commands:

wget ''
sudo bash minione

During the installation you will get a report like this:

### Checks & detection
Checking AppArmor  SKIP will try to modify

### Main deployment steps:
Install OpenNebula frontend version 5.10
Configure bridge minionebr with IP
Enable NAT over wlp2s0
Modify AppArmor
Install OpenNebula KVM node
Export appliance and update VM template

Do you agree? [yes/no]:

### Installation
Updating APT cache  OK
Download augeas lens oned.aug  OK
Creating bridge interface minionebr  OK
Bring bridge interfaces up  OK
Configuring NAT using iptables  OK
Saving iptables changes  OK
Installing DNSMasq  OK
Starting DNSMasq  OK
Configuring repositories  OK
Updating APT cache  OK
Installing OpenNebula packages  OK
Installing Ruby gems  OK
Installing OpenNebula node packages  OK
Updating AppArmor  OK
Disable default libvirtd networking  OK
Restart libvirtd  OK

### Configuration
Switching OneGate endpoint in oned.conf  OK
Switching scheduler interval in oned.conf  OK
Setting initial password for current user and oneadmin  OK
Changing WebUI to listen on port 80  OK
Starting OpenNebula services  OK
Enabling OpenNebula services  OK
Add ssh key to oneadmin user  OK
Update ssh configs to allow VM addresses reusig  OK
Ensure own hostname is resolvable  OK
Checking OpenNebula is working  OK
Disabling ssh from virtual network  OK
Adding localhost ssh key to known_hosts  OK
Testing ssh connection to localhost  OK
Updating datastores, TM_MAD=qcow2, SHARED=yes  OK
Creating KVM host  OK
Creating virtual network  OK
Exporting [CentOS 7] from Marketplace to local datastore  OK
Updating VM template  OK

### Report
OpenNebula 5.10 was installed
Sunstone [the webui] is runninng on:
Use following to login:
  user: oneadmin
  password: 48h4dE8arj


Step 2: Download ISO Images

Windows 10 ISO

You need a Windows 10 installation ISO file.  A Windows 10 Enterprise evaluation ISO can be downloaded from

VirtIO Drivers for Windows

VirtIO is a virtualization standard for network and disk device drivers. You can download the stable ISO of VirtIO drivers and additional software agents for Windows virtual machines running on KVM from

wget -O /archive/ISOS/virtio-win.iso

OpenNebula Windows VM Contextualization

Finally, you need the addon that provides contextualization package for the Windows guest virtual machines running in the OpenNebula cloud. Based on the provided contextualization parameters, the packages prepare the networking in the running guest virtual machine, set passwords, run custom start scripts, and many others. The ISO can be downloaded here.

wget -O /archive/ISOS/one-context-5.10.0.iso


The ISO images should be downloaded in a folder of the frontend server that oneadmin user can access


Step 3: Register and Create Images in the Datastore

The following commands will be executed as the oneadmin user. You can run the following command to see the available datastores:

onedatastore list
   2 files      231.1G 32% 0             0 fil  fs      ssh     on  
   1 default    231.1G 32% 0             0 img  fs      qcow2   on  
   0 system     231.1G 32% 0             0 sys  -       qcow2   on  

You need to create CDROM images on the default datastore (ID=1) for the ISO images that have been downloaded in the previous step.

oneimage create -d 1 --name "Windows 10 ISO" --path /archive/ISOS/win10.iso --type CDROM
oneimage create -d 1 --name "Virtio Windows Drivers ISO" --path /archive/ISOS/virtio-win.iso --type CDROM
oneimage create -d 1 --name "ONE Windows Context ISO" --path /archive/ISOS/virtio-win.iso --type CDROM

You need to create also an empty disk to be used for the installation of Windows 10 operating system by running

oneimage create -d 1 --name "Windows 10" --type DATABLOCK --size 45G --persistent


Use persistent flag for the DATABLOCK image so the changes made inside the VM will be saved back to the datastore after the VM is terminated

You can check if the images are ready by running:

oneimage list
  ID USER     GROUP    NAME                          DATASTORE     SIZE TYPE PER STAT RVMS
   4 oneadmin oneadmin Windows 10                    default        45G DB   Yes rdy     0
   3 oneadmin oneadmin ONE Windows Context ISO       default         1M CD    No rdy     0
   2 oneadmin oneadmin Virtio Windows Drivers ISO    default       355M CD    No rdy     0
   1 oneadmin oneadmin Windows 10 ISO                default       4.6G CD    No rdy     0


Step 4: Create a VM for Windows Installation

Now, you need need to create a VM template in order to proceed with the installation of Windows 10 by writing a file (template.txt) with the following content:

NAME = "Windows 10 Installation"
MEMORY = "16384"
CPU = "4"
VCPU = "4"

DISK = [
  IMAGE = "Windows 10 ISO",
  IMAGE_UNAME = "oneadmin" ]
DISK = [
  IMAGE = "Virtio Windows Drivers ISO",
  IMAGE_UNAME = "oneadmin" ]
DISK = [
  IMAGE = "ONE Windows Context ISO",
  IMAGE_UNAME = "oneadmin" ]
DISK = [
  DEV_PREFIX = "vd",
  IMAGE = "Windows 10",
  IMAGE_UNAME = "oneadmin" ]

NIC = [
  NETWORK = "vnet",
  NETWORK_UNAME = "oneadmin",
  MODEL = "virtio" ]

  LISTEN = "",
  TYPE = "VNC" ]

  BUS = "usb",
  TYPE = "tablet" ]

OS = [
  BOOT = "disk0" ]


For the "Windows 10" DATABLOCK image and the Network, VirtIO should be specified, in particular, DEV_PREFIX=vd for the image, and MODEL=virtio for the network. For the INPUT section, BUS=usb and TYPE=tablet is needed to avoid issues with the mouse pointer when connecting to the VM via VNC.

and then executing:

onetemplate create template.txt

You can check the templates by running:

onetemplate list
  ID USER     GROUP    NAME                                 REGTIME
   1 oneadmin oneadmin Windows 10 Installation       04/29 07:40:19
   0 oneadmin oneadmin CentOS 7                      04/29 07:31:49

You have to create a Virtual Machine to proceed with the installation of Windows by running:

onetemplate instantiate 1

You can connect to the Sunstone portal by using oneadmin (username and password are provided by the miniONE installation report). Once you login, you can connect to the Windows virtual machine by using the integrated VNC console in Sunstone and proceed with Windows installation. You will need to install VirtIO drivers for the virtual SCSI controller, for the network card and for the PCI device that is used to control the memory ballooning. Have a look at this screencast to see how to do that.


Step 5: Create a VM template for Windows Virtual Machines

Once the installation of Windows has been completed, we can proceed to terminate the VM:

onevm terminate 0

You need to change the image disk with Windows 10 installed from Datablock to OS and to non persistent:

oneimage chtype 4 OS
oneimage nonpersistent 4

You can build a VM template that can be used for creating Windows 10 Virtual Machines. Add the following content to a file "win_template.txt"

NAME="Windows 10 Enterprise"


  IMAGE="Windows 10",
  IMAGE_UNAME="oneadmin" ]
  TYPE="VNC" ]

  TYPE="tablet" ]



and then run:

onetemplate create win_template.txt

You can create a Windows 10 Virtual Machine by running:

onetemplate instantiate 2

Voilà! :-)


Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.