How To Install KVM On Ubuntu And Run Virtual Machines

How To Install KVM On Ubuntu And Run Virtual Machines

Kernel Virtual Machine (KVM) is one of the popular virtualization solutions available today to run guest  Operating Systems (Virtual Machines) on a Linux hosts (Physical Machines). Few other popular alternatives are Oracle VirtualBox, VMware Player / Workstation and Xen. In this article, we will focus on installing KVM on Ubuntu and running a guest Virtual Machine.

Recommended Prerequisites

You will need a processor that supports hardware virtualization. To see if your processor supports it, run “egrep -c ‘(vmx|svm)’ /proc/cpuinfo“. If the output is greater than 0 then your all set. But you still need to check if the feature has been enable in your  BIOS, to check run “kvm-ok“. This should generate the following output,

output-1

Note: To run “kvm-ok” command you will need the “cpu-checker” package installed. To install, simply run the command “sudo apt-get install cpu-checker“.

It is also recommended to run a 64 bit host operating system, but not required. First, to check if you have a 64 bit processor, run “egrep -c ‘ lm ‘ /proc/cpuinfo“. Again, if the output is greater than 0, then you should be good. Next, to check if your OS is running a 64 bit kernel, run command “uname -m“. This should generate the below output,

output-2

KVM Installation

Once you have sufficed the pre-requisites, to install KVM on Ubuntu and run guest Virtual Machines, simply run the command “sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils“. This will install the related software packages. Also optionally, to manage Virtual Machines using a GUI front-end, install the “virt-manager” package by running the command “sudo apt-get install virt-manager“. Once done, reboot the machine and you should be ready to use KVM. To verify if your  installation was successful, run “virsh -c qemu:///system list” or alternatively launch the Virtual Machine Manager application. The earlier command should generate the below output if the install was a success.

output-3

Creating & Running a Virtual Machine

Now that we are done installing KVM and related packages we can create and run Virtual Machines. To get started, lets create a Virtual Machine as an example. Launch the Virtual Machine Manager and click on the “Create a new virtual machine” icon in the top left. (See below screen shot)

kvm-1This brings up the “New VM” wizard. Follow the wizard as shown in the screen shots below to create a new Virtual Machine.

kvm-2

kvm-3kvm-4kvm-5kvm-6Lastly, click “Finish” to begin guest operating system installation on the new Virtual Machine. If you have tried or use other similar virtualization products, let me know how you like KVM in contrast.

Advertisements

Posted on June 14, 2015, in Linux (Ubuntu/CentOS). Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: