Solution Verified in:
- OpenNebula: 6.4
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.
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:
The video above was recorded for OpenNebula 5.10, but it can be performed in the same way in OpenNebula 6.4 since there are no significant differences in the process.
Download ISO Images
Windows 10 ISO
You need a Windows 10 installation ISO file. A Windows 10 Enterprise evaluation ISO can be downloaded from https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise
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 https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/
wget -O /archive/ISOS/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/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 https://github.com/OpenNebula/addon-context-windows/releases/download/v5.10.0/one-context-5.10.0.iso
The ISO images should be downloaded in a folder of the frontend server that oneadmin user can access
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 ID NAME SIZE AVA CLUSTERS IMAGES TYPE DS TM STAT 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 can use the
--source parameter on the
oneimage create command to create images on the image datastore directly. This will save up time by avoiding the initial download to the filesystem. However, some images might be locked behind authentication and other user input validations.
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 OS --size 45G --persistent
The disk musk be persistent so the changes made during the setup persist afterwards. 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
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" MEMORY_UNIT_COST = "MB" 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", SECURITY_GROUPS = "0" ] NIC_DEFAULT = [ MODEL = "virtio" ] GRAPHICS = [ LISTEN = "0.0.0.0", TYPE = "VNC" ] INPUT = [ BUS = "usb", TYPE = "tablet" ] OS = [ BOOT = "disk0" ]
For the "Windows 10" OS 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
- Disable TPM for Windows 11 using the registry
- install VirtIO drivers
- install qemu guest agent
- install OpenSSH server
- install the contextualization package for Windows Guest OS
- optionally install WinRM
Have a look at this screencast to see how to do that.
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 to non persistent:
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" CPU="4" VCPU="4" MEMORY="16384" MEMORY_UNIT_COST="MB" DISK=[ DEV_PREFIX="vd", IMAGE="Windows 10", IMAGE_UNAME="oneadmin" ] GRAPHICS=[ LISTEN="0.0.0.0", TYPE="VNC" ] INPUT=[ BUS="usb", TYPE="tablet" ] NIC=[ NETWORK="vnet", NETWORK_UNAME="oneadmin", SECURITY_GROUPS="0" ] CONTEXT=[ NETWORK="YES", SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]" ]
and then run:
onetemplate create win_template.txt
You can create a Windows 10 Virtual Machine by running:
onetemplate instantiate 2