KVM on Centos

From Devipedia

Jump to: navigation, search


Installing KVM on Centos


Install the KVM packages, qemu, libvirt and virt-manager

yum install kvm qemu virt-manager libvirt

The next step is to modprobe the kvm module for your architecture. If it's an Intel processor:

modprobe kvm-intel

If it's an AMD processor:

modprobe kvm-amd

If all goes well, you should have the kvm module loaded on your system by now. You can check this by running:

/sbin/lsmod | grep kvm

Setup Bridge

If you want to access the virtual machine from the LAN, you'll need to set up a bridge on one or more of your network interfaces. Once this step is complete, virt-manager will take care of the remaining details when setting up a virtual machine using the GUI.

Check that a default bridge is configured. Run brctl show and you should see something like this.

[root@machine ~]# brctl show
bridge name	bridge id		STP enabled	interfaces
virbr0		8000.000000000000	yes		
vnet0		8000.000000000000	yes		

Create a file in network-scripts called ifcfg-vnet0...

vim /etc/sysconfig/network-scripts/ifcfg-vnet0

...and add the following if you want to configure the bridge for eth0:


Now add the bridge:

 brctl addif vnet0 eth0

Now you'll see:

[root@machine ~]# brctl show
bridge name	bridge id		STP enabled	interfaces
virbr0		8000.000000000000	yes		
vnet0		8000.003048625732	no		eth0

To make this sticky (available after reboot), add BRIDGE=vnet0 to /etc/sysconfig/network-scripts/ifcfg-eth0.

Create the Virtual Machine

It's possible to create a virtual machine from the command line like this:

qemu-kvm -hda windisk.img -cdrom winimg.iso -m 1024 -boot d

However, it's probably easier to manage things using virt-manager. Launch from the UI or from the command line.


Click on the first row to highlight it, right-click and select new to open the wizard. Follow the steps including choice of ISO and where to write the image. When you get to the network screen, choose Shared Physical Device and you will see your bridged eth0 interface. If you skipped bridging, you will not have this option so take a different one.

Once complete, start up the VM. Done.

Personal tools