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.
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,
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,
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.
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)
Lastly, 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.