Create a VM Image in OpenNebula

Test­ed on Open­Neb­u­la 4.4.1 on Cen­tOS 6.5. It should work on recent Open­Neb­u­la ver­sions.

This is almost copied from Tuto­r­i­al: Deploy VM Using Image Cre­at­ed On Open­Neb­u­la Direct­ly, for preser­va­tion and my own per­son­al use. Check the orig­i­nal link first.

Step 1. Uploading the Installation CD Image

a. Go to Virtual Resources -> Images -> Create
b. Set Type to CDROM.
c. Leave Persistent unchecked.
d. Use either Provide a path and set it to a URL point­ing to an OS instal­la­tion image or Upload and set it to an already down­loaded OS instal­la­tion image.

We now have an instal­la­tion cdrom image in our data­s­tore

Step 2. Creating an empty hard disk (Datablock)

a. Goto Virtual Resources -> Images -> Create
b. Set Type to Dat­a­block
c. Tick Persistent. Every change made to this dat­a­block needs to per­sist since this is going to be the hard dri­ve for each new­ly deployed VM.
d. e. Set Image Location to Emp­ty dat­a­block, set Size and (option­al­ly) FS type and FS Driver to qcow2.
e. Set Driver prefix to sd.
f. Last time I wasn’t set­ting FS Driver to qcow2 and ONE would barf

This will cre­ate an emp­ty dat­a­block which will be used to install the OS.

Step 3. Creating an OS image installation template

a. Goto Virtual Resources -> Templates -> Create
b. We are going to use the instal­la­tion CD (Step 1) and the Dat­a­block (Step 2). So, in Storage attach the instal­la­tion CD and set READONLY to yes and attach the dat­a­block as well.
c. Set the Net­work (select a nic)
d. Under OS Booting: In Boot set Boot to CDROM and in Features set ACPI to yes.
e. Under Input/Output set VNC and Listen IP to
f. Under Context tick Add Network contextualisation and Add OnGate token.

Step 4. Deploy a VM based on the OS image installation template (Step 3)

a. Instan­ti­ate the tem­plate. This will cre­ate a VM, which will boot from the CDROM (Step 1) and install the OS in the dat­a­block disk (Step2).
b. Shut­down the VM when instal­la­tion is com­plete and delete the VM. Remem­ber, our dat­a­block is per­sis­tent so the OS is installed and all changes are per­sis­tent.
c. Goto Virtual Resources -> Images and change its Type from Dat­a­block to OS.

Step 5. Create a VM preparation template.

a. Cre­ate a nor­mal tem­plate. Under Storage attach only the disk we cre­at­ed on Step 4. The VM boots from this disk.
b. NB: don’t do this is you want to have noVNC work­ing!! Under Other pass the fol­low­ing in the RAW data sec­tion and set the Type to KVM. in order to enable ser­i­al con­sole access, from KVM side. This requires to enable it from the VM’s ker­nel side as well by tweak­ing the grub con­fig file that spec­i­fies ker­nel options dur­ing boot.
<devices><serial type="pty"><source path="/dev/pts/5"/><target port="0"/></serial><console type="pty" tty="/dev/pts/5"><source path="/dev/pts/5"/><target port="0"/></console></devices>
c. All oth­er set­tings just like Step 3.

Instan­ti­ate the tem­plate and start a VM.

Step 6. Contextualisation

In our new­ly cre­at­ed VM:

a. Go to Basic Con­tex­tu­al­i­sa­tion. The process is not straight for­ward so here’s a rough guide.
— Open VM’s VNC con­sole.
— Set­up the net­work for the VM.
— Set­up ONE repos­i­to­ry and install the con­tex­tu­al­i­sa­tion deb pack­age. UPDATE: Down­load it man­u­al­ly at since I can’t find it in the ONE repo.
b. NB: don’t do this is you want to have noVNC work­ing!! To enable ser­i­al con­sole access from the VM side, open /etc/default/grub and set the fol­low­ing:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
— Cre­ate /etc/init/ttyS0.conf with the fol­low­ing con­tents:
# ttyS0 - getty
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.
start on stopped rc or RUNLEVEL=[12345]
stop on runlevel [!12345]
exec /sbin/getty -L -w 115200 ttyS0 vt102

— Full instruc­tions at
b. Pre­pare the VM, i.e. clean and make it pris­tine, fol­low­ing this guide.
c. Shut­down the VM and delete it.

Final­ly go to the OS image and set its Type to non per­sis­tent.

We can now use the OS image to instan­ti­ate new VMs.

This entry was posted in OpenNebula. Bookmark the permalink.

Comments are closed.