1 Objectives

snf-image is an image creation plugin for Ganeti which comes from the Synnefo cloud platform.

NOTE: all the commands in this exercise are run as the root user. If you are logged in as a regular user, use sudo -s to get a root shell.

$ sudo -s

2 Install snf-image

(Do this on all nodes).

You need to add the grnet repository.

First, create a file /etc/apt/sources.list.d/grnet.list containing exactly the following two lines:

deb http://apt.dev.grnet.gr wheezy/
deb-src http://apt.dev.grnet.gr wheezy/

Now add the repository signing key:

# wget -O - https://dev.grnet.gr/files/apt-grnetdev.pub | apt-key add -

Finally, install the package:

# apt-get update
# apt-get install snf-image

During the installation, you will be prompted (twice) for the URL to download the snf-image-helper from. Both times, change it from




(you should be able to use Ctrl-U to delete the existing URL and then paste in the new one). This is so that you fetch a local copy. Otherwise it will take a very long time to download across the Internet - it's over 200MB.

3 Fetch an image

A number of sample images are available.

For testing we'll use one of the smaller ones, Debian Wheezy Base. This is still over 500MB so you need to fetch it from a local copy:

# cd /var/lib/snf-image
# wget http://www.ws.nsrc.org/downloads/synnefo/debian_base-7.0-x86_64.diskdump

4 Installing instances (creating VMs)

Creating a fully-working image is now just a one-step operation. Login to the MASTER node of your cluster, and run the following command:

# gnt-instance add -o snf-image+default \
  -t plain -s 1G -n hostX.ws.nsrc.org \
  -O img_passwd=abc123,img_format=diskdump,img_id=debian_base-7.0-x86_64,img_properties='{"OSFAMILY":"linux"\,"ROOT_PARTITION":"1"\,"USERS":"root"}' \
  --no-name-check --no-ip-check --net 0:link=br-lan wheezyX

(replacing X in hostX and wheezyX with your host number)

The instance will be immediately started and ready to use.

5 Configuring the network service

Since the VM is connected to br-lan it should have picked up an IP address via DHCP, but you still need to find out what it is.

Log in using VNC to the console of your VM - if you're in doubt which node it's running on, use

# gnt-instance list -o +network_port

Once logged in to the guest:

# ifconfig eth0

Test that connectivity works, by pinging the class webserver:

# ping -c5 www.ws.nsrc.org

Does it work ?

Now you know its IP address, you should also be able to SSH to your instance from your laptop. Login as root with the password selected when you created the instance.

6 Additional info

To find out how to create your own images for deployment with snf-image, see the documentation for snf-image-creator

7 Instance export and import

You can try exporting the VM:

# gnt-backup export -n hostY.ws.nsrc.org wheezyX

If the instance is running then it is temporarily shut down.

The node (-n) where you want the export to be written does not have to be the same as the node where the instance is.

The backup image is written under /var/lib/ganeti/export/wheezyX/ on hostY.

When you import it's similar to creating a new instance, and you can use most of the flags you use when creating a new instance. This means you can use this as an alternative way of cloning machines. However by default ganeti will try to re-create the new machine with the same MAC address as the old one, which is rejected:

Failure: prerequisites not met for this operation:
error type: resource_not_unique, error details:
MAC address aa:00:00:41:1f:57 already in use in cluster

Therefore you have to tell it to assign a new MAC address when importing if the exported instance is still present.

# gnt-backup import \
  --src-node hostY.ws.nsrc.org --src-dir /var/lib/ganeti/export/wheezyX \
  -t plain -s 2G -n hostZ.ws.nsrc.org --no-name-check --no-ip-check \
  --net 0:mac=generate,link=br-lan wheezyX-copy


If that completes successfully, you can start it:

# gnt-instance start wheezyX-copy

Note however that even though you have created a larger disk (2G), the partition table and filesystem are still from the 1G disk, so "df" will show only 1G available.