OSETC TECH

Use Cloud Images to Create Virtual Machines with Uvtool

This post will guide you how to use cloud images to create virtual machines with KVM in Ubuntu Linux. How do I create a virtual machine using a cloud images with uvtool on Ubuntu Linux 16.04/14.04.

What is 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.

Create VM with Uvtool in Ubuntu


If you want to create a virtual machine with uvtool in Ubuntu Linux, just do the following steps:

#1 Install and Configure KVM

Type the following command to install and configure KVM on Ubuntu Linux:

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
# kvm-ok
# apt install virt-manager
# virt-manager

# 2 Install uvtool Pakcage

Type the following command to install uvtool package:

# apt install uvtool  -y

This command will install uvtool’s ain commands: uvt-simplestreams-libvirt and uvt-kvm.

#3 get the Ubuntu cloud image

You can execute uvt-simplestreams-libvirt to download the Ubuntu cloud image, type:

$ uvt-simplestreams-libvirt sync arch=amd64

This command will download all the Ubuntu cloud images from the office site.

And you can run the following command to check what has been downloaded:

$ uvt-simplestreams-libvirt query

Outputs:

$ 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)

#4 Generate the SSH Keys

Type the following command:

# ssh-keygen

Outputs:

[root@devops ~]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:R25TT2+VUXIU7eCNRsCe55nIr2iY7eMr4F8TNFNUZDc root@devops

The key's randomart image is:

+---[RSA 2048]----+

|           o++=EO|

|           ...o+=|

|          =..+.*.|

|         + +oo=.+|

|        S *. =.oo|

|      .  o oo +. |

|     . . +o  .   |

|      . +.+o  .  |

|       ..==o..   |

+----[SHA256]-----+

#5 create the VM using uvt-kvm

Type  the following command:

# uvt-kvm create vm1

Get the list of running Ubuntu cloud image VMs

Type the following command:

# uvt-kvm list

Destroy VM

Type the following command:

# uvt-kvm destroy vm1