Virtualization With KVM On A CentOS 6.4 Server


This guide explains how you can install and use KVM for creating and running virtual machines on a CentOS 6.4 server. I will show how to create image-based virtual machines and also virtual machines that use a logical volume (LVM). KVM is short for Kernel-based Virtual Machine and makes use of hardware virtualization, i.e., you need a CPU that supports hardware virtualization, e.g. Intel VT or AMD-V.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I’m using a CentOS 6.4 server with the hostname and the IP address here as my KVM host.

I had SELinux disabled on my CentOS 6.4 system. I didn’t test with SELinux on; it might work, but if not, you better switch off SELinux as well:

vi /etc/selinux/config

Set SELINUX=disabled…

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.

… and reboot:


We also need a desktop system where we install virt-manager so that we can connect to the graphical console of the virtual machines that we install. I’m using a Fedora 17 desktop here.


2 Installing KVM

CentOS 6.4 KVM Host:

First check if your CPU supports hardware virtualization – if this is the case, the command

egrep ‘(vmx|svm)’ –color=always /proc/cpuinfo

should display something, e.g. like this:

[root@server1 ~]# egrep ‘(vmx|svm)’ –color=always /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy misalignsse
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy misalignsse
[root@server1 ~]#

If nothing is displayed, then your processor doesn’t support hardware virtualization, and you must stop here.

Now we import the GPG keys for software packages:

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*

To install KVM and virtinst (a tool to create virtual machines), we run

yum install kvm libvirt python-virtinst qemu-kvm

Then start the libvirt daemon:

/etc/init.d/libvirtd start

To check if KVM has successfully been installed, run

virsh -c qemu:///system list

It should display something like this:

[root@server1 ~]# virsh -c qemu:///system list
Id Name                 State

[root@server1 ~]#

If it displays an error instead, then something went wrong.

Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network.

To do this, we install the package bridge-utils…

yum install bridge-utils

… and configure a bridge. Create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the IPADDR, PREFIX, GATEWAY, DNS1 and DNS2 values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file); make sure you use TYPE=Bridge, not TYPE=Ethernet:

vi /etc/sysconfig/network-scripts/ifcfg-br0

NAME="System br0"

Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follows (comment out BOOTPROTO, IPADDR, PREFIX, GATEWAY, DNS1, and DNS2 and add BRIDGE=br0):

vi /etc/sysconfig/network-scripts/ifcfg-eth0

NAME="System eth0"

Restart the network…

/etc/init.d/network restart

… and run


It should now show the network bridge (br0):

[root@server1 ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
inet addr:  Bcast:  Mask:
inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:460 (460.0 b)  TX bytes:2298 (2.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
RX packets:18455 errors:0 dropped:0 overruns:0 frame:0
TX packets:11861 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26163057 (24.9 MiB)  TX bytes:1100370 (1.0 MiB)
Interrupt:25 Base address:0xe000

lo        Link encap:Local Loopback
inet addr:  Mask:
inet6 addr: ::1/128 Scope:Host
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2456 (2.3 KiB)  TX bytes:2456 (2.3 KiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:AC:AC:8F
inet addr:  Bcast:  Mask:
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@server1 ~]#


3 Installing virt-viewer Or virt-manager On Your Fedora 17 Desktop

Fedora 17 Desktop:

We need a means of connecting to the graphical console of our guests – we can use virt-manager for this. I’m assuming that you’re using a Fedora 17 desktop.

Become root…


… and run…

yum install virt-manager libvirt qemu-system-x86 openssh-askpass

… to install virt-manager.

(If you’re using an Ubuntu 12.04 desktop, you can install virt-manager as follows:

sudo apt-get install virt-manager



4 Creating A Debian Squeeze Guest (Image-Based) From The Command Line

CentOs 6.4 KVM Host:

Now let’s go back to our CentOS 6.4 KVM host.

Take a look at

man virt-install

to learn how to use virt-install.

We will create our image-based virtual machines in the directory /var/lib/libvirt/images/ which was created automatically when we installed KVM in chapter two.

To create a Debian Squeeze guest (in bridging mode) with the name vm10, 512MB of RAM, two virtual CPUs, and the disk image /var/lib/libvirt/images/vm10.img (with a size of 12GB), insert the Debian Squeeze Netinstall CD into the CD drive and run

virt-install –connect qemu:///system -n vm10 -r 512 –vcpus=2 –disk path=/var/lib/libvirt/images/vm10.img,size=12 -c /dev/cdrom –vnc –noautoconsole –os-type linux –os-variant debiansqueeze –accelerate –network=bridge:br0 –hvm

Of course, you can also create an ISO image of the Debian Squeeze Netinstall CD (please create it in the /var/lib/libvirt/images/ directory because later on I will show how to create virtual machines through virt-manager from your Fedora desktop, and virt-manager will look for ISO images in the /var/lib/libvirt/images/ directory)…

dd if=/dev/cdrom of=/var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso

… and use the ISO image in the virt-install command:

virt-install –connect qemu:///system -n vm10 -r 512 –vcpus=2 –disk path=/var/lib/libvirt/images/vm10.img,size=12 -c /var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso –vnc –noautoconsole –os-type linux –os-variant debiansqueeze –accelerate –network=bridge:br0 –hvm

The output is as follows:

[root@server1 ~]# virt-install –connect qemu:///system -n vm10 -r 512 –vcpus=2 –disk path=/var/lib/libvirt/images/vm10.img,size=12 -c /var/lib/libvirt/images/debian-6.0.5-amd64-netinst.iso –vnc –noautoconsole –os-type linux –os-variant debiansqueeze –accelerate –network=bridge:br0 –hvm

Starting install…
Allocating ‘vm10.img’              |  12 GB     00:00
Creating domain…                 |    0 B     00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
[root@server1 ~]#

Click on Link for Page 2 :-

Click on Link for Page 3 :-

Click on Link for Page 4 :-

Click on Link for Page 5 :-

Original Link :-

Hope this will helps you all, If you face any issue regarding the same or its not working for your some how then please raise your questions / issues then comment down below.

If you like this then Please Click Google +1 Button and Show Your Support. Your Support will encourage me to write more articles.

All Linux User’s Blog Mobile Applications :-

Please Keep in Touch with Social Networking :- 

Facebook Page :-

Enjoy Virtualization on Linux 🙂 Enjoy Linux 🙂 Enjoy Linux Open Source 🙂

Setup and Configuration of a Virtual Machine in Virtual Box

VirtualBox is an operating system virtualization program that allows you, the end user, to do an incredible number of things that you couldn’t otherwise do in any other way than in a live environment.  But not everyone has more than one machine laying around with an OS installed on it, and not everyone wants to have to dual or multi boot in order to use each of these OS’s.

That’s where VirtualBox comes in handy.  You can test an operating system, or run more than one OS simultaneously without needing multiple PC’s.  But what does it take to get started with Virtualbox?  Well, I’m about to show you.  (be sure you already have Virtualbox 3.x installed before starting this tutorial)

Setting up a Virtual Machine

To get started setting up a Virtual Machine, begin by opening VirtualBox.  On the left side you’ll see a large white column with four buttons over it.  Click on “New”.  This will bring up a new windows.  Click “Next”.  In this window you’ll want to enter a name for the Virtual Machine.  Typically this is the name of the OS you’ll be using, however it doesn’t necessarily have to be.

For example, if you’re simply testing Linux distributions, just name it “Linux Testing” or something that makes sense to you so you know what it is.  Essentially the name is just there to make sure you know which is which if you have more than one Virtual Machine.

Now, in the section below that text box, select the operating system and version you’ll be using.  For example, with Windows you’d choose “Microsoft Windows” and “Windows XP” respectively.  Virtualbox 3.x can support Windows, Linux, Solaris, BSD and IBM OS/2 (yes, OS2.  Kinda surprising, isn’t it?  hehe) natively, and there’s an “other” category for other OS’s that don’t fall into one of those six categories.

Those typically are things like Dos, Novel Netware, L4, QNX, or some other off the wall OS that will run on x86 hardware, but isn’t a mainstream OS.  Next, choose the base memory that your virtual machine will use.  Typically this should be no more than 50% of your total available physical memory.  So if you only have 1gb of ram, don’t select more than 512mb of memory for your Virtual Machine, or bad things may happen.

Now, click next, and either choose an existing hard drive, or create a new one.  Note, these are virtual hard drives.  They’ll appear as files on your main system drive, but won’t affect it in any way, other than to take up space.  If you haven’t created a virtual hard drive yet, click “Create new hard disk” and then click next.

A new window should appear.  Click next.  Now you will be asked if you want dynamically expanding storage, or fixed.  Dynamically expanding storage is essentially a disk image that grows as you need more space.  Typically this is the best way to setup a virtual drive, as you only use as much space as you absolutely need.  It will continue to grow over time as you need more space, up to the maximum limit, but not beyond.

The second type of drive is fixed size storage.  This will automatically allocated the entire amount of space required for your virtual drive right at the beginning, even if you are only using a small portion of it within the Virtual Machine.  Now, once you’ve chosen this, select a location to store the virtual drive, and a disk size.

Now in regards to disk size, regardless which type you choose (dynamic or fixed), you will need to make sure that you select a drive size no more than 50% of your total available disk space.  So for example, if your physical hard drive is 80gb, your virtual drive should be no more than 40gb.

Once you’re done with that, click finish and it will take you back to the previous window.  Simply click next, and finish, and you’re done.


The next step now is to configure the Virtual Machine.  Start by clicking on your new Virtual Machine in the left column, then click settings.  In here you can change anything you like about your Virtual Machine.  There aren’t many tweaks that I would recommend in here, however there are a few.  One of those is to adjust your video memory.

To do that, click on “display” in the left column.  On the right side panel, look at the total memory listed there (it won’t let you go any higher than 100% of your video memory), and then either move the slider over until it’s at 50% of your total memory, or you can manually specify the value in the the box at the far end.

Never, ever, ever go over 50% of your total physical video memory for the same reasons you should never go over 50% of your total physical ram.  Bad things happen if you do.  What you essentially do is you starve your host system for memory and that can quickly come back to haunt you.

Below the memory slider is a neat new addition to Virtual Box.  It allows you to have full 3D support within your virtual machine.  It’s still experimental, but it works.  To use it, just check the little box there, and then click ok.  There are other things in there you can play with and tweak if you like, but if not, then you’re done.

Install the OS

This last part is the shortest, and easiest part of the entire process of setting up your Virtual Machine.  Namely, installing the OS.  Overall, there are two ways in which you can do this.  The first is directly with a CD or DVD of the OS.

To do that, insert the install disk into your cd or dvd drive, and then, with the Virtual Machine selected, click on “CD/DVD-ROM” in the right side panel.  This will take you back into the settings dialog.  Checkmark “Mount CD/DVD Drive”, then select your drive from the list, if you have more than one, and then click ok.  If you only have only one, just click OK.

Inversely, if you are installing from a disk iso, you can simply select “ISO Image File” here, then click the folder icon next to it.  This will open the Virtual Media Manager.  To add your iso file, click “Add”, then browse to the file and click Open.  You’ll now see your iso file in the list.  Just select it, and then click “select”.

This will return you to the previous window.  Click ok.  Now click start and follow the prompts to install your OS.  Once it has completely finished with the disk, you can remove it by simply selecting “Devices -> Unmount CD/DVD-ROM” from the Virtual Machine window.


Well, that’s all it.  You’ve completed your setup and you are now ready to begin playing with your new Virtual Machine!

Original Post :-

Installing & Configuring VirtualBox on Fedora 9/10.

Hi Friends,

I am Sharing Method that How to Install Virtulbox on Fedora.

Follow this steps to install Virtualbox on fedora

Step 1:- First you have to download & install this rpm by executing following command:
wget && rpm -ivh VirtualBox-2.0.6_39765_fedora9-1.i386.rpm

Step 2:-Now get the kernel-devel Package:-

yum install make automake autoconf gcc kernel-devel dkms

Step 3:- Now Run the setup file for Virtualbox:-

/etc/init.d/vboxdrv setup

Step 4:- Now Add yourself to the vboxusers group and fix the SELinux Permission:-

usermod -G vboxusers -a <your-username>
chcon -t textrel_shlib_t /usr/lib/virtualbox/

Step 5:- Execute This command to Run VirtualBox
or you can find this under Applications -> System Tools -> VirtualBox