Tuesday, July 28, 2009

Oracle VM Templates on Xen 3.2

Oracle VM Templates are a great way to test Oracle Software with little to no setup and install. You simply download the template and import it into your VM and you should be good to go.

However, importing an Oracle VM template into OVM and Xen are two different things (although they shouldn't be).

The first thing you will want to do is unarchive the template into the directory of your choice:

tar zxvf OVM_EL5U2_X86_64_PVM_10GB.tgz

This should give you the following directory structure:


Next, copy the vm.cfg file into your xen directory with a new name:

cp vm.cfg /etc/xen/OEL5U2.cfg

Now, edit the OEL5U2.cfg and change the disk= line to point to your System.img file. Just change the directory to the place where you unarchived it. You will also want to change the
file: parameter to tap:aio:. On OVM, the file parameter has changes that make it very efficient. On Xen, tap:aio is far superior to file. Here is what my config looks like:

disk = [ 'tap:aio:/home/images/OVM_EL5U2_X86_64_PVM_10GB/System.img,xvda,w' ]

You will also want to verify that your bootloader line points to your pygrub binary. If it does not, change it. Mine looks like this:


Feel free to make other changes such as memory and vcpus based on your needs.

Here is where this gets fun.

You will need kpartx to mount partitions from the img file. If you do not have it installed, get it from your linux vendor.

First, set up the associations for the image file by running the following command:

kpartx -av /home/images/OVM_EL5U2_X86_64_PVM_10GB/System.img

Replace the location with your location of the System.img file.

Next, we need to let LVM know about these new partitions:


You should get something like the following back:

Found volume group "VolGroup00" using metadata type lvm2

Now, activate the logical volumes with the following:

vgchange -ay VolGroup00

running 'lvs' should show the new partitions. Now you can mount the logical volume partitions like you would any other partition:

mount /dev/VolGroup/LogVol00 /mnt

Change into the directory and make the following change to your kernel line.
1) Remove the 'quiet' parameter
2) Add console=xvc0 to it.

My grub.conf:

title Enterprise Linux Enterprise Linux Server (2.6.18-
root (hd0,0)
kernel /vmlinuz-2.6.18- ro root=/dev/VolGroup00/LogVol00 rhgb numa=off console=xvc0
initrd /initrd-2.6.18-

Save the file.

Unmount the partition:

umount /mnt

Deactivate the Volume Group

vchange -an VolGrou00

Remove the img associations:

kpartx -dv /home/images/OVM_EL5U2_X86_64_PVM_10GB/System.img

Now, you should be able to boot the image without issues:

xm create OEL5U2.cfg

Good Luck!

1 comment:

Don Safar said...

Great Job. I was able to follow your instructions to get Oracle Enterprise 5v4 up and running under xen on Centos. Only instruction that didn't work was - the last vgchange command. One question - I can get it to come up using the xm create command. How do I make it a permanent entry in virt-manager (it doesn't show up after I shut it down)?

Official, Youbetcha Legalese

This blog is provided for information purposes only and the contents hereof are subject to change without notice. This blog contains links to articles, sites, blogs, that are created by entities other than Oracle. These links may contain advice, information, and opinion that is incorrect or untested. This blog, links, and other materials contained or referenced in this blog are not warranted to be error-free, nor are they subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this blog, links and other materials contained or referenced in this blog, and no contractual obligations are formed either directly or indirectly by this blog, link or other materials. This blog may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission. The opinions and recommendations contained in this blog(including links) do not represent the position of Oracle Corporation.

Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.