Cloud images and uvtool


With Ubuntu being one of the most used operating systems on many cloud platforms, the availability of stable and secure cloud images has become very important. As of 12.04 the utilization of cloud images outside of a cloud infrastructure has been improved. It is now possible to use those images to create a virtual machine without the need of a complete installation.

Création de machines virtuelles utilisant uvtool

Starting with 14.04 LTS, a tool called uvtool greatly facilitates the task of generating virtual machines (VM) using the cloud images. uvtool provides a simple mechanism to synchronize cloud-images locally and use them to create new VMs in minutes.

Paquets Uvtool

The following packages and their dependencies will be required in order to use uvtool:

  • uvtool

  • uvtool-libvirt

To install uvtool, run:

$ apt -y install uvtool

Ceci installera les commandes principales de uvtool :

  • uvt-simplestreams-libvirt

  • uvt-kvm

Get the Ubuntu Cloud Image with uvt-simplestreams-libvirt

This is one of the major simplifications that uvtool brings. It is aware of where to find the cloud images so only one command is required to get a new cloud image. For instance, if you want to synchronize all cloud images for the amd64 architecture, the uvtool command would be:

$ uvt-simplestreams-libvirt sync arch=amd64

After an amount of time required to download all the images from the Internet, you will have a complete set of cloud images stored locally. To see what has been downloaded use the following command:

$ uvt-simplestreams-libvirt query
release=oneiric arch=amd64 label=release (20130509)
release=precise arch=amd64 label=release (20160315)
release=quantal arch=amd64 label=release (20140409)
release=raring arch=amd64 label=release (20140111)
release=saucy arch=amd64 label=release (20140709)
release=trusty arch=amd64 label=release (20160314)
release=utopic arch=amd64 label=release (20150723)
release=vivid arch=amd64 label=release (20160203)
release=wily arch=amd64 label=release (20160315)
release=xenial arch=amd64 label=beta1 (20160223.1)

In the case where you want to synchronize only one specific cloud-image, you need to use the release= and arch= filters to identify which image needs to be synchronized.

$ uvt-simplestreams-libvirt sync release=xenial arch=amd64

Créez la machine virtuelle à l'aide de uvt-kvm

In order to connect to the virtual machine once it has been created, you must have a valid SSH key available for the Ubuntu user. If your environment does not have an SSH key, you can easily create one using the following command:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/
The key fingerprint is:
4d:ba:5d:57:c9:49:ef:b5:ab:71:14:56:6e:2b:ad:9b ubuntu@xenialS
The key's randomart image is:
+--[ RSA 2048]----+
|               ..|
|              o.=|
|          .    **|
|         +    o+=|
|        S . ...=.|
|         o . .+ .|
|        . .  o o |
|              *  |
|             E   |

To create of a new virtual machine using uvtool, run the following in a terminal:

$ uvt-kvm create firsttest

This will create a VM named firsttest using the current LTS cloud image available locally. If you want to specify a release to be used to create the VM, you need to use the release= filter:

$ uvt-kvm create secondtest release=xenial

uvt-kvm wait can be used to wait until the creation of the VM has completed:

$ uvt-kvm wait secondttest --insecure
Warning: secure wait for boot-finished not yet implemented; use --insecure.

Connectez-vous à la machine virtuelle en cours d'exécution

Once the virtual machine creation is completed, you can connect to it using SSH:

$ uvt-kvm ssh secondtest --insecure

For the time being, the --insecure is required, so use this mechanism to connect to your VM only if you completely trust your network infrastructure.

You can also connect to your VM using a regular SSH session using the IP address of the VM. The address can be queried using the following command:

$ uvt-kvm ip secondtest
$ ssh -i ~/.ssh/id_rsa ubuntu@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:8oxaztRWzTMtv8SC9LYyjuqBu79Z9JP8bUGh6G8R8cw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
Welcome to Ubuntu Xenial Xerus (development branch) (GNU/Linux 4.4.0-X-generic ARCH)

 * Documentation:

  Get cloud support with Ubuntu Advantage Cloud Guest:

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.


Obtenez la liste des machines virtuelles en cours d'exécution

You can get the list of VMs running on your system with this command:

$ uvt-kvm list

Détruisez votre machine virtuelle

Once you are done with your VM, you can destroy it with:

$ uvt-kvm destroy secondtest

Plus d'options uvt-kvm

The following options can be used to change some of the characteristics of the VM that you are creating:

  • --memory : Amount of RAM in megabytes. Default: 512.

  • --disk : Size of the OS disk in gigabytes. Default: 8.

  • --cpu : Number of CPU cores. Default: 1.

Some other parameters will have an impact on the cloud-init configuration:

  • --password password : Allow login to the VM using the Ubuntu account and this provided password.

  • --run-script-once script_file : Run script_file as root on the VM the first time it is booted, but never again.

  • --packages package_list : Install the comma-separated packages specified in package_list on first boot.

A complete description of all available modifiers is available in the manpage of uvt-kvm.


Si vous voulez en apprendre davantage, si vous avez des questions ou des suggestions, veuillez contacter l'équipe Ubuntu Server à cette adresse :