1 Objectives

You are going to import a tiny Ubuntu 14.04 installation called "Jeos" from the vmdk software appliance provided.

Since Ganeti won't work directly with vmdk files, you are going to convert it into a logical volume. This will work efficiently because there will be no fragmentation on the host; it can also be converted easily to DRBD if you wish.

2 Importing a VMDK

Do this part of this exercise on whichever host you want the virtual machine to be created on. For example, if you are working with host2 then login to host2, not the cluster master node.

2.1 Examine the file

Have a look at the file you're going to use:

# ls -l /iso/ub1404lts-disk1.vmdk
-rw-r--r-- 1 root root 88965632 Jun  5 15:04 /iso/ub1404lts-disk1.vmdk

That doesn't tell us much, because a VMDK file is an image which grows as it is used. What you need to know is the size of the disk drive which is being emulated, and you can find this out using qemu-img info

# qemu-img info /iso/ub1404lts-disk1.vmdk
image: /iso/ub1404lts-disk1.vmdk
file format: vmdk
virtual size: 1.0G (1073741824 bytes)
disk size: 85M

(Note that this is using Gibibytes, where 1GiB = 1024^3 bytes)

Let's just check this is exactly 1GiB, using a calculator program bc:

# bc
(ctrl-D to exit)

Yes, that matches exactly.

2.2 Create Logical Volume

Now create a logical volume of exactly that size.

# lvcreate --size 1G --name jeosX ganeti

(replacing X with your group number, e.g. on host2 use jeos2. This ensures all the logical volume names are unique)

Type lvs to see that your logical volume is present. Also check that a new block device has been created under /dev/ganeti

# ls -l /dev/ganeti/jeosX
lrwxrwxrwx 1 root root 7 May 15 09:32 /dev/ganeti/jeosX -> ../dm-3

2.3 Convert the image

Now unpack the VMDK and write it to this volume:

# qemu-img convert -O raw /iso/ub1404lts-disk1.vmdk /dev/ganeti/jeosX

This will take a few seconds.

3 Create VM

Now login to the cluster MASTER node.

You will create an instance and tell Ganeti to adopt the logical volume you have created.

# gnt-instance add -t plain -o noop \
    -n hostX.ws.nsrc.org \
    --disk 0:adopt=jeosX \
    -B minmem=128M,maxmem=256M \
    --no-name-check --no-ip-check jeosX

The -n flag gives the node where you created the logical volume.

This will take over the given logical volume and rename it to the Ganeti standard (UUID-based), without running any OS installation; and since we didn't specify --no-start it will also start it running.

3.1 Login to the VM

Connect to your VM's VNC console - by now you should know how to do this, or ask for help.

At the console, login as root/root, and type ifconfig to find out what IP address your VM has picked up via DHCP.

Jeos is a very minimal install, it doesn't even have an openssh server. To install packages, first configure it to use our local package proxy by typing vi /etc/apt/apt.conf and putting in this one line:

Acquire::http::Proxy "http://apt.ws.nsrc.org:3142/";

Then run:

# apt-get update
# apt-get install openssh-server acpid

Now you should be able to ssh into your VM on its IP address; you will need to login as user/user because root logins over ssh are disabled.

We installed acpid because this allows Ganeti to signal to it to shutdown. That is, you can safely shut it down from the master node using

# gnt-instance shutdown jeosX

Congratulations, you have installed a VM software appliance!

4 Additional notes

4.1 Conversion to DRBD

Once you have created a "plain" disk image, it's straightforward to convert it to "drbd" so that you have a resilient service and can live-migrate it back and forth. Shut it down, and then do:

# gnt-instance modify -t drbd -n hostY.ws.nsrc.org jeosX

Check which are the primary and secondary nodes using:

# gnt-instance list -o name,pnode,snodes,network_port jeosX

Then you can start it again. When it's running, live-migrate it using

# gnt-instance migrate jeosX

You should then find that the primary and secondary nodes have swapped.

4.2 Direct access to instance disks

In this exercise we first created a new logical volume and then got Ganeti to adopt it to in a new virtual machine.

With an existing virtual machine, sometimes you might want to overwrite the contents of an existing logical volume (while the VM is not running of course), for example using dd.

This is acceptable for a VM running with a plain image - although you run the risk of accidentally writing to the wrong logical volume and damaging another VM!

But if you have an existing VM with DRBD, then you MUST NEVER write directly to the underlying LVM volumes, or this will completely mess up the replication.

For the safe way to access the disks of a DRBD instance, see the section Accessing an Instance's Disks in the Ganeti administrator's guide.