Issue
I am a big fan of Opennebula because of some of features such as good support for virtual networking and vmware and documentation. One of the biggest attractions is that is it truly open source. Opennebula has way to pass parameters from the Sunstone interface and pre-defined templates to provision a new virtual machine(vm) via context. We tried to provision some vm's with Centos 6 and it worked great using Opennebula-context rpm package install in the base image. Unfortunately the context package did not work for Centos 5.
Diagnosis
We first installed
one-context.rpm on a Centos 5 image. Upon provisioning a new guest, We noticed that the context was not being implement. Such as the hostname not being update to what we typed in the Sunstone interface.
We then looked at
Opennebula-context in Github. /etc/init.d/vmcontext is the main service which runs all the context.
Upon closer inspection, the cdrom was not being mounted and that /dev/disk/by-label/CONTEXT symlink was missing. /dev/disk/by-label/CONTEXT was symlink to /dev/sr0 on Centos 6 which was named differently on Centos 5.
Centos 6
/dev/sr0
Centos 5
/dev/hdb
On the Centos 5 guest vm. We manually symlinked to the cdrom:
cd /dev/disk/by-label
ln -sf ../../hdb CONTEXT
Test vmcontext service:
service vmcontext start
We received : "mount: no such partition found" which was tracked down to this line in /etc/init.d/vmcontext
mount -t iso9660 -L CONTEXT -o ro /mnt
If we run the following first then the line above would work. Weird.
mount /dev/disk/by-label/CONTEXT -o ro /mnt
umount /mnt
mount -t iso9660 -L CONTEXT -o ro /mnt
Solution
Perform these steps on the Centos 5 base image before you import into Opennebula
vi /etc/init.d/vmcontext
change
mount -t iso9660 -L CONTEXT -o ro /mnt
to
mount /dev/disk/by-label/CONTEXT -o ro /mnt
To make the symlink correct cdrom device we need to update udev
vi /etc/udev/rules.d/50-udev.rules
change
KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom", SYMLINK+="cdrom cdrom-%k"
to
KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom", SYMLINK+="cdrom cdrom-%k disk/by-label/CONTEXT"
comment out
BUS=="ide", KERNEL=="hd*[0-9]", SYSFS{../removable}=="1", GOTO="persistent_end"
to
#BUS=="ide", KERNEL=="hd*[0-9]", SYSFS{../removable}=="1", GOTO="persistent_end"