Converting an Oracle VM VirtualBox VM into an Oracle VM Server image

As we are working on tighter seemless moving of VM's between the 2 products, here are a few simple steps to convert an existing Oracle VM VirtualBox image over.

Steps involved to make it easy/straightforward :

(1) When creating a VM in Virtualbox, using Oracle Linux as an example, make sure that /etc/fstab only uses labels. Do not use hardcoded device names.

instead of an entry

/dev/sda1 /u01 ext3 defaults 1 1

use

LABEL=foo /u01 ext3 defaults 1 1

for more info on labels : man e2label

or use a logical volume

/dev/VolGroup00/LVfoo /u01 ext3 defaults 1 1

Doing so will make it easier to have an OS boot up on a different hypervisor with potentially different device names. For instance, the VirtualBox VM might expose a scsi driver while in Oracle VM Server you might end up with an ide disk, this then changes /dev/sda to /dev/hda.

(2) If you have a VM created that you want to convert, then shut down the VM in VirtualBox and convert the image files :

go the the directory that contains your HardDisk image files (.VirtualBox/HardDisks/* as an example)

for each of the virtual disks run the following command :

VBoxManage clonehd virtualdiskfilename.vdi system.img --format raw

where virtualdiskfilename.vdi is the original VBox VM file (this can also be a vmdk file) and system.img is the name of the virtualdisk for Oracle VM. this can be any filename as well, I typically use system.img to specify the boot disk (as is common for Oracle VM template creation)

(3) create a vm.cfg

To run a VM converted from VirtualBox, you have to create a vm.cfg for Oracle VM server that creates an HVM guest. The easiest is to use a simple hvm vm.cfg and change it for your vm. I have an example here :

acpi = 1
apic = 1
builder = 'hvm'
device_model = '/usr/lib/xen/bin/qemu-dm'
disk = ['file:system.img,hda,w', 'file:oracle.img,hdb,w',',hdc:cdrom,r',]
kernel = '/usr/lib/xen/boot/hvmloader'
memory = '1024'
name = 'vmname'
on_crash = 'restart'
on_reboot = 'restart'
pae = 1
serial = 'pty'
timer_mode = '0'
usbdevice = 'tablet'
vcpus = 1
vif = ['bridge=xenbr0,type=ioemu']
vif_other_config = []
vnc = 1
vncconsole = 1
vnclisten = '0.0.0.0'
vncpasswd = ''
vncunused = 1

If you take the above vm.cfg, all you need to do

- modify disk = (add your virtual disks in there)
- modify memory = (amount of memory your VM needs)
- modify name = (enter a name for your VM here)
- modify vif = (might want to replace bridge=xenbr0 to the bridge you want to use)

if you want more than 1 vcpu or other changes of course you have to make those as well.

(4) copy this set of files onto your Oracle VM server or onto a webserver in a subdirectory and import the template through Oracle VM Manager. You can also just start the vm using xm create vm.cfg if you like.

And that's it. As I said, we are working on automation around all this but it is relatively trivial to convert VM's over as long as you take the basic issues into account. Primarily the set up of the filesystems and the use of labels in /etc/fstab.

There are other potential things to look at, such as network config. If you want to make that part clean then prior to shutting down the VM change /etc/modprobe.conf and/or add the mac address of the VM into the vm.cfg in the vifs line. The good thing, at least with Linux, is that even tho the virtual hardware changes, Linux will deal with it just fine (e1000 vs 8139 realtek, ide vs scsi etc).

hope this helps.


Comments:

Hi Wim,
Just wondering if this process will still work with the latest release of Oracle VM (OVM 3.0)?
Thanks,
Mark

Posted by guest on September 27, 2011 at 01:52 PM PDT #

Is there a way to convert the VM Server Image to open in VrtualBox?

Posted by James on April 01, 2012 at 11:07 PM PDT #

Hi Wim,

nice blog. couldn't find anything on this front online.

few questions though:

1) does it still work on 3.2.2 Oracle VM?
2) what do you mean by "copy this set of files onto your Oracle VM server"
can you provide more details? what files? img and cfg? or only img?

what i tried to do is import the converted disk (img file) to my repository and then create a machine and attach to it this disk. is this enough?

Thx
Elie

Posted by guest on May 30, 2013 at 04:48 AM PDT #

1) yes should all still work in 3.2.2

actually easier now - you can export as a virtual appliance in vbox (.ova) and import the .ova file in ovm3 through the manager

Posted by guest on June 13, 2013 at 09:35 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Wim Coekaerts is the Senior Vice President of Linux and Virtualization Engineering for Oracle. He is responsible for Oracle's complete desktop to data center virtualization product line and the Oracle Linux support program.

You can follow him on Twitter at @wimcoekaerts

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
9
10
11
12
13
14
15
16
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today