In this tutorial, I will show you how to install KVM and create a virtual machine on Ubuntu desktop. There are two ways to create virtual machines using KVM: using the command line tool virsh and using the graphical tool called virt-manager. I will introduce the usage of virt-manager. virt-manager can use either QEMU or KVM as its hypervisor.
Check Your CPU’s Hardware Virtualization Capability
Your CPU need to support hardware virtualization in order to use KVM. The following command will search svm and vmx in /proc/cpuinfo file and return how many instances it found.
egrep -c ‘(svm|vmx)’ /proc/cpuinfo
The virtualization technology used in AMD processors is called AMD-V. The CPU flag for AMD-V is svm which stands for secure virtual machine.
Intel processors use VT-x to support hardware virtualization for x86 platforms. The CPU flag for VT-x is vmx and it stands for virtual machine extensions.
So if the above command returns number 0 in your terminal, that means your CPU does not support hardware virtualization and you have to use Virtualbox or VMware to create virtual machines. If it returns a number greater than 0, then you CPU supports hardware virtualization and you can continue to read this article to learn how to use KVM. For example, my computer has a quad core Intel CPU and all of them provide VT-x support, so this command returns number 4.
Virtualization technology can still be disabled in your computer’s BIOS so make sure you have enabled virtualization feature in the BIOS setup.
Install KVM on Ubuntu
Use the following command to install KVM on Ubuntu
sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager virtinst virt-viewer
The bridge-utils is used to create bridge networking so other devices on your network can see your virtual machine.
Create Virtual Machines With KVM
Launch the graphical tool virt-manager from Dash. Its name in the applications menu is virtual machine manager.
In the virtual machine manager window, click the first icon in the toolbar.
Choose the location of your installation media. I chose local install media.
Then specify the path of your iso image and select the OS type and version. I chose a ubuntu iso image.
Next, allocate memory and CPU to your virtual machine.
After that, specify the size of your virtual disk. virtual disk by default is dynamic. That means the real disk size will grow with demand. If you check the box before allocate entire disk now, then the disk size is fixed.
In the next window, you can give your virtual machine a name. Then click finish to begin installing OS to your virtual machine.
The installation process begins.
Here’s a screenshot of ubuntu vritual machine running in virt-manger window.