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/grnetdev.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 for a URL prefix to download the snf-image-helper from. Paste in the following:


This is so that you fetch a local copy. Otherwise it will take a very long time to download across the Internet from http://cdn.synnefo.org/ - 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 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

The VM should be connected to the default network (br-svc) and have picked up an IP address via DHCP, but you still need to find out what address it has.

Log in using VNC to the console of your VM - if you're in doubt which node or port to connect to, 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

6.1 Creating images

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

6.2 Creating variants

To avoid having to give a long set of parameters using the -O flag every time you create an instance, snf-image from 0.15.1 onwards supports the use of OS variants.

On the master node, create /etc/ganeti/snf-image/variants/wheezy.conf containing the following:


and edit /etc/ganeti/snf-image/variants.list so it looks like this:


Push this file out to all the other nodes:

# cd /etc/ganeti/snf-image
# gnt-cluster copyfile variants/wheezy.conf
# gnt-cluster copyfile variants.list

and check using gnt-os list that your new variant (snf-image+wheezy) is visible. If it isn't, use gnt-os diagnose for more details; maybe it is missing on some of the cluster nodes.

Now you can create an image using simply -o snf-image+wheezy without having to provide the -O parameters.

6.3 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-svc 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.

It would be up to you to fix the partition table and grow the filesystem to fit the larger space available.