I have been doing some Oracle VM benchmark stuff in the last week or 2 in my off hours and yesterday I wanted to convert one of my VMs that was based on a paravirt kernel into a vm that just boots as a regular hardware virt VM with a standard x86-64 kernel.
It took me a little while to figure out the fastest way so now that I have it pretty much down I wanted to share the steps.
A PV kernel uses pygrub and a paravirt kernel image that lives on the vm image virtual disk. since this disk image does not have to be bootable it doesn't contain a boot sector and if you just restart the VM in hvm mode the virtual bios will just not do much as it can't start the boot process from disk
The first thing I do is make a backup of my vm.cfg file :-) and then edit it as follows :
the original file contains :
bootloader = '/usr/bin/pygrub'
I replace that with :
acpi = 1
apic = 1
builder = 'hvm'
device_model = '/usr/lib/xen/bin/qemu-dm'
kernel = '/usr/lib/xen/boot/hvmloader'
then changing the disk files.
I change my xvd disks to hd disks and I copy over the iso image of my instal lDVD. In the case of my VM template it was based on OL5U4 So I downloaded Enterprise-R5-U4-Server-x86_64-dvd.iso and added it as a cd device.
disk = ['file:/ovs/OVM_EL5U4_X86_64_11202RAC_PVM/System.img,xvda,w',
'file:/ovs/OVM_EL5U4_X86_64_11202RAC_PVM/Oracle11202RAC_x86_64-xvdb.img,xvdb,w',
]
to
disk = ['file:/ovs/OVM_EL5U4_X86_64_11202RAC_PVM/System.img,hda,w',
'file:/ovs/OVM_EL5U4_X86_64_11202RAC_PVM/Oracle11202RAC_x86_64-xvdb.img,hdb,w',
'file:/ovs/OVM_EL5U4_X86_64_11202RAC_PVM/Enterprise-R5-U4-Server-x86_64-dvd.iso,
hdc:cdrom,r',
]
boot='d'
for the network devices (vifs) I change :
vif = ['bridge=xenbr2,type=netfront']
to
vif = ['bridge=xenbr2,type=ioemu']
That should do it.
Next, inside the VM, I copy over the regular kernel rpm that I want to end up running in hvm mode. In this example case it was : kernel-2.6.18-164.0.0.0.1.el5.x8664.rpm. I will use that later on in the process. I put this kernel simply in /root
At this point I just start the vm with xm create vm.cfg and start my vnc console to the vm console. Oracle Linux will boot from the iso image, I just go through the install steps and click on UPgrade existing (not re-install). Because the VM is the same as the ISO the install won't actually do anything and it will run through instantly.
When the "Reboot" button pops up, don't reboot. Switch to the command prompt console. hi alt-f2 to go to the shell prompt. Now it's easy :
umount /mnt/sysimage/boot
cd /mnt/sysimage
chroot .
mount /dev/hda1 (if that was your /boot partition)
export PATH=/sbin:$PATH (just to clean that up)
edit /etc/modprobe.conf and comment out the xen modules (just put a # in front)
Install grub. if your /boot is hda1 then that is (hd0,0)
$ grub
root (hd0,0)
setup (hd0)
exit grub
now you have a good bootsector, grub installed and you have your grub.conf file
Install the new kernel
cd root (this is your old /root in your pv image)
rpm -ivh
remove (or comment out) boot='d' in your vm.cfg
restart the VM and you should be good to go, regular grub should start and load your environment.
Caveats : this assumes you used labels for your filesystems. if /etc/fstab were to have devices listed then you would have to rename these device before rebooting as well. If you had a /dev/xvda disk then this would be /dev/hda or /dev/sda.
All in all it is a relatively short and simple process.