Create your first Virtual machine in RHEL/CentOS using KVM

Use of virtualization is on rise, more & more enterprises are adopting it. Perhaps the biggest advantage of using it cost saving. Companies save on hardware resources, space & reduced power consumption. &One of the major player in the field of virtualization is KVM technology.

KVM or Kernel Based Virtualization Machine is a Hardware based virtualization software that provide a Linux system capability to run multiple operating systems in Linux environment. It can run Linux as well as Windows family OS.KVM uses QEMU for I/O hardware emulation. QEMU is a user-space emulator that can emulate avariety of guest processors on host processors with decent performance.

KVM/QEMU can be managed either graphically or through CLI. We use virt-manager for managing virtual machines, it can create, delete, edit & can also cold/live migrate guest machines between hosts. For managing virtual machine through CLI, we use a CLI utility called ‘virsh’  & has been discussed in details in our post on “Managing virtual machines using CLI


  • 1- Processor with Hardware virtualization support

As mentioned above, KVM is a hardware based virtualzation software & we will need processors that support it. So firstly we need to make sure that our processor supports the technology before installing KVM. To do so run the following command on your terminal,

$ egrep ‘(vmx|svm)’ /proc/cpuinfo

So if your processor is Intel based, it must support Intel VT& you should get “VMX” as the output of the command or if using AMD based processor, it must support AMD-V& output for the command should be “SVM”.

  • 2- A bridged network adapter adapter

By default VMs on KVM will have access to other VMs only. But if we want VMs to access LAN we need configure a bridged adapter on our machine. To create a bridged adapter, copy interface file for current network interface ‘ifcfg-en0s1’ to another file for bridge interface named ‘ifcfg-br0’

$ cd /etc/sysconfig/network-scripts/
$ cp ifcfg-en0s1 ifcfg-br0

Now we will edit the file ‘ifcfg-br0’,

$ vi ifcfg-br0

DNS1=$ vi ifcfg-br0

Change network settings as per your own network requirements. Save the file & restart network services.

$ systemctl restart network

And our bridged adapter has been configured.



For installing KVM on our machine we will require some packages, these are qemu-kvm which is QEMU emulator & main package for KVM, qemu-img is QEMU disk image manager,virt-install is a command line tool to create virtual machines, libvirt provides daemon to manage virtual machines and controls hypervisor, libvirt-client provides client side API’s for accessing servers and virsh utility provides command line tool to manage virtual machines & lastly virt-viewer is the graphical console. We will install all these packages using yum,

$ yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer

Lastly start virtualization daemon called ‘libvertd’,

$ systemctl restart libvertd

Next we will now create virtual machine on KVM server with the help of virt-manager.


Creating a Virtual Machine

We will launch ‘virt-manager’ to create our first virtual machine. You can launch virt-manager either using CLI or graphically. For CLI, launch your terminal & type

$ virt-manager

Or for graphical interface, search for ’Virtual machine manager ‘ in Application under System Tools. Once it has been launched, goto ‘File’ & click on ‘New Virtual Machine’

  • – If using an ISO image for installation, select ‘Local Install Media’ for installing OS,
  • – Next , select the location for your ISO image & click Forward,
  • – On the next page, select ‘Memory’ & number of ‘CPUs’ & click Forward,
  • – Specify the storage size for your VM & click Forward,
  • – On the last page will be the summary forthe VM, review all the configurations & in Network selection menu, select bridged adapter ‘br0’ & hit finish.

Now install the OS as you normally do & boot into VM once the installation has been completed. We can create as many VMs as necessary & as much our resources permit using the same procedure.

Shujat Husain

A continuous learner with several years of experience in linux environment. I love to read, learn & write about Linux & new technologies. And I also write at

What is in your mind, about this post ? Leave a Reply

  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us