# 1 Objectives

You are going to install an application called "Netdot" using 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/netdot-1.0.6-ubuntu-12.04.vmdk
-rw-r--r-- 1 nsrc nsrc 1672413184 Apr 11 16:54 /iso/netdot-1.0.6-ubuntu-12.04.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/netdot-1.0.6-ubuntu-12.04.vmdk
image: /iso/netdot-1.0.6-ubuntu-12.04.vmdk
file format: vmdk
virtual size: 21G (22548578304 bytes)
disk size: 1.6G

Let's just check this is exactly 21GB, using a calculator program bc:

# bc
21*1024*1024*1024
22548578304
(ctrl-D to exit)

Yes, that matches exactly.

## 2.2 Create Logical Volume

Now create a logical volume of exactly that size.

# lvcreate --size 21G --name netdotX ganeti

(replacing X with your group number, e.g. on host2 use netdot2. 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/netdotX
lrwxrwxrwx 1 root root 7 May 15 09:32 /dev/ganeti/netdotX -> ../dm-3

## 2.3 Convert the image

Now unpack the VMDK and write it to this volume:

# qemu-img convert -O raw /iso/netdot-1.0.6-ubuntu-12.04.vmdk \
/dev/ganeti/netdotX
• -O raw says the format you want the output to be written in (just a raw stream of blocks)
• The next parameter is the input you are reading
• The final parameter is where you want to write the output

This will take a little while.

# 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 image+cd \
-n hostX.ws.nsrc.org \
-B minmem=512M,maxmem=1G \
--no-name-check --no-ip-check --no-start \
netdotX

This will take over the given logical volume and rename it to the Ganeti standard (UUID-based), without running any OS installation.

## 3.1 Start the VM

Netdot is a management application, so let's attach it to our internal network on the br-lan bridge. This also lets it pick up an IP address via DHCP. Again, run these commands on the MASTER node.

# gnt-instance modify --net 0:modify,link=br-lan netdotX

Once this is done, you can start the VM as normal.

# gnt-instance start netdotX

You can login using either the VNC console or the serial console - by now you should know how to do this.

At the console, login as netdot/netdot and find what IP address it has picked up (ifconfig). Then you can point your web browser at

http://10.10.0.NNN/netdot

Congratulations, you have installed a VM software appliance!

Note: 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. However in this classroom there might not be enough disk space on the nodes you are working on for you to do this.

# 4 Warning: DRBD

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.