HOW TO CREATE VMS FROM CUSTOM IMAGES?

The 0.12 release of Synnefo introduces a new feature: the ability to create VMs from your own, pre-existing machines. And since your machines come in all shapes and colors, the VMs created from them will preserve all your settings such as partition schemes, installed programs etc.

We have created a new tool for this, the snf-image-creator, which you can install on your machine (host machine) and use it to snapshot an existing OS installation. Before you plunge into this guide however, we suggest you read the respective FAQ section where we explain some limits of the Image creation method we present below.

The outline of the creation process is the following:

Step 1: Install snf-image-creator on your host machine

You can read a detailed guide on how to install snf-image-creator on the Installation section of snf-image-creator's documentation.

Note that since snf-image-creator works faster on virtualization capable hardware, you may want to check if your CPU has virtualization extensions. If it does, then the following command will produce some output:

$ grep -E 'svm|vmx' /proc/cpuinfo

Step 2: Create and upload an OS image

Now that you have installed snf-image-creator, you can use it to create an image of any OS installation that lies on a media, such as a block device or a regular raw file, that can be accessed by your host machine.

In the following example, we will use snf-image-creator to create a clone of an existing ~okeanos VM. You can use the same commands if you want to create an image of your home computer. However, be sure to check out first the Caveats and Limitations sections of snf-image-creator's documentation, which present a few requirements on your OS installation.

You should also know that there are actually two variants of snf-image-creator, both achieving the same results but suited for different needs:

  • snf-image-creator is a user-friendly dialog-based program. Its "Wizard" mode is suited for users who want a quick and simple way to upload their OS images.
  • snf-mkimage is a non-interactive command line program that receives all the necessary information (account info, image info etc.) as options. It is ideal for scripting purposes.

Let's see both tools in action. The next commands must be entered on the prompt of your host machine (an Ubuntu 12.04.2 VM in this case).

snf-image-creator

In order to use snf-image-creator, simply type:

$ sudo snf-image-creator /

The "/" is used to indicate that you want to create an image of your host machine.

NOTE: If other OS installations exist on the same machine, you can instead create an image out of them. In this case, you would provide the path where they are installed. You can check an example here. This functionality comes in handy when you want to create an image from a Windows OS, as explained in the respective FAQ section.

snf-image-creator will initially check if the media really is a disk or a raw file representing a hard disk. Then, it will use heuristics to understand which OS has been installed on the media. After that, you will be asked which mode you prefer:

userguide mkimage-wizard

  • Wizard mode is intuitive and consists of 4 simple steps.
  • Expert mode has an abundance of options but requires a bit of knowledge of the inner workings of Cyclades from your part and thus is out of the scope of this tutorial. You can find out more though, on the snf-image-creator documentation.

So, for this example you can choose "Wizard". If this is the first time you use snf-image-creator, you will be asked to provide your credentials for your ~okeanos account. Also, the word "cloud" that you see refers to ~okeanos in our context but it can also refer to any Synnefo deployment. More specifically, you will be asked to provide the following:

  • Name: This is a name of preference that you can give to this Synnefo deployment (and yes, there are more than one). It can be any word e.g. "okeanos", "trial", "mycloud" with no spaces.
  • [Description]: You can optionally give a more detailed description to this cloud entry.
  • Authentication URL: This is the URL that you see at the API access tab of your profile in ~okeanos.
  • Token: This is the token you can find right below the Authentication URL in the API access tab.

(Alternatively, you could copy your .kamakirc to your VM and the snf-image-creator won't ask you for the above)

For our example, we have used the following setup:

userguide mkimage-cloud

Then, choose the entry you have just created

userguide mkimage-entry

and provide a name for the ~okeanos Image you want to upload.

userguide mkimage1

This name will serve as the Image's filename.

Then, provide a description for the Image.

userguide mkimage2

This will be a short description of your Image.

Next, choose if you want to make your ~okeanos Image publicly available or not.

userguide mkimage3

and you're done! A confirmation message will appear on your screen. You can then proceed to the Image creation by clicking "Next". A similar list operations will appear on your console.

userguide mkimage-results

We will comment on the above output briefly.

  • Sysprep: Operations from 1/9 to 9/9 are part of the system preparation operations and are best explained in the snf-image-creator's Usage section.
  • Shrinking: In order to minimize the image size and the uploading time, we shrink the image as much as possible. You can find out more here.
  • MD5SUM: The md5sum of the image is used later on to verify that the image has been uploaded successfully.
  • Uploading: Before you upload an OS image, every block is hashed, checked against existing blocks in Pithos+ and finally uploaded, if no other block has the same hash. Essentially, this is data deduplication.

Finally, after the image has been uploaded successfully, you will be asked whether you want to save a local copy of the shrunken image. This is just a copy of the diskdump that has been uploaded to Pithos+ and, in case you are confused, the original OS installed on the media remains intact.

snf-mkimage

snf-mkimage is the command-line alternative to snf-image-creator. Its full set of options can be found in the Usage section of snf-image-creator's documentation.

This tool is most commonly used with the following set of options:

$ sudo snf-mkimage / -a https://accounts.okeanos.grnet.gr/identity/v2.0/ \
-t myT0k3n== -u ubuntu.diskdump -r "Ubuntu 12.04.2 LTS"

As you can see, these options are exactly what snf-image-creator's steps translate to. You can also see that the output is nearly identical:

userguide image-creator

Step 3: Create your VM

Creating a VM out of an uploaded custom ~okeanos Image is a fairly simple task. Just select "New Machine", go to "My Images" section and select your Image.

userguide custom-vm

Alternatively, if you want to create a VM from another user's custom ~okeanos Image, you can go to the "Public Images" section.