Thursday, March 20, 2014

Creating a Windows Guest on Oracle Database Appliance(ODA) Virtualized Platform

When it comes to deploying a Windows guest as a virtual machine on Oracle's ODA, the documentation is lacking.  After some research and trial and error, I was able to put together a process that will successfully install Windows.

The ODA utilizes the oakcli command line, so OVM is not an option.  In this post, I will walk through the steps needed to prepare and deploy a Windows 7 virtual machine.

Here is a high level summary of the steps.

1. Create an unformatted virtual disk image
2. Create a configuration file for the VM template
3. Create a shared repository
4. Import the VM template
5. Clone a VM from the template
6. Boot from iso file and install Windows
7. Configure Windows network
8. Install Paravirtialized Drivers on Windows guest
9. Modify VM's network


NOTE: For the purposes of this example, all logins for Dom0 and ODA_BASE are on node 0.

First, we need to log into Domain 0 (Dom0) and create an empty unformatted virtual disk image.  The image file name must be System.img.  In the example below, the file size is fixed at 50G.

$ mkdir /OVS/staging/vm_temp/win7x64

$ dd if=/dev/zero of=/OVS/staging/vm_temp/win7x64/System.img oflag=direct bs=1M count=51200


In the same staging directory, create a vm.cfg file with the following content.  The "boot" parameter is set as "dc" which sets the CDROM first in the boot order.  The "disk" parameter names the System.img file created above as the device "hda" in "read/write" mode.  Before the Paravirtualized Drivers(PV) get installed, the "vif" parameter needs to be set with a type of "ioemu".  Later, when the VM is started, a vnc session for the console will be started.  The vnc port is set in the "vfb" parameter with a vncdisplay of 10.  The 10 sets the port to 5910.  A value of 1 would set it to 5901.

kernel = 'hvmloader'
builder = 'hvm'
vcpus = '4'
memory = '4096'
boot = 'dc'
disk = ['file:/OVS/staging/vm_temp/win7x64/System.img,hda,w']
name = 'win7x64'
vif = [ 'type=ioemu,bridge=net1' ]
on_poweroff = 'destroy'
on_reboot = 'destroy'
on_crash = 'destroy'
acpi = '1'
apic = '1'
usbdevice='tablet'
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=10' ]


The next step is creating the tar file containing the two files created above to be imported.

$ cd /OVS/staging/vm_temp/win7x64

$ tar -Sczvf win7x64.tgz System.img vm.cfg


There are default repositories created as part of the ODA_BASE.  The repos "odarepo1" and "odarepo2" are local repositories and will not allow VMs running from these repos to fail over to the other node.  To avoid this, create a shared repository.

NOTE:  Once you create the repo, the size cannot be changed, so plan accordingly.

Log on to ODA_BASE and run the following command to create a 150GB shared repository in the DATA disk group.

$ oakcli create repo odashr -size 150G -dg DATA


Now the environment is set up to import the template.  Login to ODA_BASE as root and run the following command.

$ oakcli import vmtemplate tmpl_win7x64 -files "/OVS/staging/vm_temp/win7x64/win7x64.tgz" -repo odashr -node 0


Once the template has been imported, the VM can finally be cloned.  Using the vmtemplate, run the following command on ODA_BASE.

$ oakcli clone vm vm_win7x64 -vmtemplate tmpl_win7x64 -repo odashr -node 0


Copy the Windows installation iso file to a staging location on Dom0.  Then modify the file /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg on Dom0 by adding the iso as a CDROM.  Below, the iso file /OVS/staging/X17-24281.iso has been defined as device "hdc" and made read only.

disk = [u'file:/OVS/Repositories/odashr/VirtualMachines/vm_win7x64/System.img,hda,w', 'file:/OVS/staging/X17-24281.iso,hdc:cdrom,r']


Now start the VM by logging into ODA_BASE and running the following command.

$ oakcli start vm vm_win7x64


Once the VM starts, log onto Dom0 and attach to the console with a VNC client using the vnc port defined above.  In our example, the port is 5910.  From the VNC console, you need to install Windows.

After the installation is complete, log into Dom0 and modify the /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg file.  Change the boot parameter from "dc" to "cd".  This will name the boot device to the virtual hard drive rather than the CDROM.

Log into ODA_BASE and restart the VM.

$ oakcli stop vm vm_win7x64

$ oakcli start vm vm_win7x64


Now attach to your vnc session again and configure the network settings for the VM guest as per your requirements.  Once the network is configured and functioning, you can download the Windows PV Drivers to the guest and install them by running the executable.  As of the date of this post, the PV drivers can be downloaded from edelivery.oracle.com.  Go to "Cloud Portal Oracle Linux/VM", and enter "Oracle VM" for the product pack and "x86 64 bit" for the platform.

After the PV drivers have been installed, modify the /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg file by changing the "vif" parameter as follows.

From

vif = [ 'type=ioemu,bridge=net1']

To

vif = [ 'type=netfront,bridge=net1']


Now restart your VM, and the guest should be ready for use.  If you want to by-pass using the vnc session, configure remote desktop and connect to the console.

$ oakcli stop vm vm_win7x64

$ oakcli start vm vm_win7x64



9 comments:

  1. David, thanks,, great article

    I have a problem,, when I create a System.img with command dd, it takes a long time,,, 50 GB on 4 Hours,, it´s normal?

    ReplyDelete
    Replies
    1. Camilo,
      I did not have that issue with the dd. It took more like 15 minutes for creating the 50GB image. I did find, however, that both the template import and the creation of the clone from the template took several hours each.

      Delete
  2. I have the same problem

    ReplyDelete
  3. where did you find system.img for windows?

    ReplyDelete
  4. I created an empty System.img file using dd. Then I attached the Windows ISO file to the VM and started it. With the VM set to boot from the CDROM, it started an install of Windows on an empty image. Once the install is complete, this VM can be used to clone other Windows VMs without the need for an installation.

    ReplyDelete
  5. Hi David
    Have you tried creating a Windows VM (2012R2) on X5-2 12.1.2.2.0?
    Having problems, need assistance
    G

    ReplyDelete
  6. Sorry G, I have not tried that configuration. What issues are you facing?

    ReplyDelete
  7. Thanks for the instructions, they were very useful to me.

    Extending a shared repository is not actually too difficult, once you figure out that it's implemented as an ACFS filesystem in ODA_BASE, and the standard acfsutil command is available.

    In my case, the pathname of the shared repository was /OVS/Repositories/sharedrepo/ in dom0, which maps to /u01/app/sharedrepo/sharedrepo/ in ODA_BASE.

    To resize this shared repository to 1500 GB, run this in ODA_BASE:
    # acfsutil size 1500G /u01/app/sharedrepo/sharedrepo
    acfsutil size: new file system size: 1610612736000 (1536000MB)

    As the shared repository is NFS mounted from ODA_BASE to dom0, you don't need to do anything to make dom0 aware of the change.

    Just remeber that when you expand a shared repository, it will take up space from one of the ASM diskgroups in ODA_BASE.
    Run "acfsutil info fs " to see which one.

    ReplyDelete
  8. Great article and awesome detailed steps. I wasn't looking to install windows on an ODA VM, however I was interested in the steps necessary to boot from an ISO for recovery purposes and this was perfect!

    ReplyDelete