Difference between revisions of "Installing KVM Virtualization on CentOS 6"

From Techotopia
Jump to: navigation, search
m (Text replacement - "<htmlet>ezoicbottom</htmlet>" to "")
m (Text replacement - "<hr> <table border=" to "<htmlet>ezoicbottom</htmlet> <hr> <table border=")
Line 134: Line 134:
  
  
 +
<htmlet>ezoicbottom</htmlet>
 
<hr>
 
<hr>
 
<table border="0" cellspacing="0">
 
<table border="0" cellspacing="0">

Revision as of 18:13, 11 May 2016

PreviousTable of ContentsNext
Configuring a CentOS 6 Postfix Email ServerCreating a CentOS 6 KVM Networked Bridge Interface


You are reading a sample chapter from the CentOS 6 Essentials Essentials book.

Purchase a copy of the fully updated CentOS 8 edition in eBook ($24.99) or Print ($36.99) format

CentOS 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 260 pages. Learn more...

Buy Print Preview Book


Virtualization is generically defined as the ability to run multiple operating systems simultaneously on a single computer system. Whilst not necessarily a new concept, Virtualization has come to prominence in recent years because it provides a way to fully utilize the CPU and resource capacity of a server system whilst providing stability (in that if one virtualized guest system crashes, the host and any other guest systems continue to run).

Virtualization is also useful in terms of trying out different operating systems without having to configure dual boot environments. For example, you can run Windows in a virtual machine without having to re-partition the disk, shut down CentOS 6 and then boot from Windows. You simply start up a virtualized version of Windows as a guest operating system. Similarly, virtualization allows you to run other Linux distributions from within a CentOS 6 system, providing concurrent access to both operating systems. Prior to CentOS 6 two virtualization platforms were provided with CentOS in the form of KVM and Xen. With the release of CentOS 6, support for Xen has been removed leaving KVM as the only bundled virtualization option supplied with CentOS 6. In addition to KVM, third party solutions are available in the form of products such as VMware and Oracle VirtualBox. Since KVM is supplied with CentOS 6, however, this is the virtualization solution that will be covered in this and subsequent chapters.

Before plunging into installing and running KVM it is worth taking a little time to talk about two different types of virtualization and the corresponding hardware requirements.


Contents


Full Virtualization, Para-Virtualization and Emulation

There are two common approaches to virtualization - full virtualization and para-virtualization. Full virtualization provides complete abstraction between the hardware and the guest operating system. In this scenario, the guest operating system is provided a complete virtual physical environment in which to run and, as such, is unaware that it is running inside a virtual machine. One advantage of full virtualization is that the operating system does not need to be modified in order to run in a virtualized environment. This means that proprietary operating systems such as Windows can be run on Linux host systems.

Disadvantages of full virtualization are that performance is slightly reduced as compared to para-virtualization, and some virtualization platforms, such as Xen and KVM, require CPUs with special virtualization support built in (such as Intel-VT and AMD-V). Some of the performance disadvantages can, however, be mitigated through the installation of para-virtualized drivers on the guest system.

Para-virtualization requires that a guest operating system be modified to support virtualization. This typically means that guest operating systems are limited to open source systems such as Linux. It is also not possible to migrate a running guest OS from one server to another. The advantage to this approach, however, is that a para-virtualized guest system comes closer to native performance than a fully virtualized guest, and the latest virtualization CPU support is not needed.

Whilst Xen supports both full and para-virtualization, KVM supports only full virtualization. As such, KVM can only be used on CPUs that support either Intel-VT or AMD-V extensions. If your processor does not have Intel-VT or AMD-V support you will still be able to install guest operating systems though this will be implemented using the QEMU environment instead of KVM virtualization. QEMU uses emulation to run guest operating systems and as such results in slower performance than the hardware assisted full-virtualization offered by KVM.

For a more detailed explanation of virtualization techniques read Virtuatopia.com’s An Overview of Virtualization Techniques:

http://www.virtuatopia.com/index.php/An_Overview_of_Virtualization_Techniques

KVM Hardware Requirements

Before proceeding with this chapter we need to take a moment to discuss the hardware requirements for running virtual machines within a KVM environment. Firstly, KVM virtualization is only available on certain processor types. These processors include either Intel-VT or AMD-V technology.

To check for Intel-VT support, run the following command in a terminal window to check for the presence of vmx:

# grep vmx /proc/cpuinfo 
flags: fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi 
mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx 
est tm2 cx16 xtpr lahf_lm

To check for AMD-V support, run the following command which checks for the presence of svm:

# grep svm /proc/cpuinfo
flags: fpu tsc msr pae mce cx8 apic mtrr 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 cr8_legacy

Note that while the above commands only report whether the processor supports the respective feature, it does not indicate whether the feature is currently enabled in the BIOS. In practice virtualization support is typically disabled in the BIOS of most systems. It is recommended, therefore, that you check your BIOS settings to ensure the appropriate virtualization technology is enabled before proceeding with this tutorial. Unlike a dual booting environment, a virtualized environment involves the running of two or more complete operating systems concurrently on a single computer system. This means that the system must have enough physical memory, disk space and CPU processing power to comfortably accommodate all these systems in parallel. Before beginning the configuration and installation process check on the minimum system requirements for both CentOS 6 and your chosen guest operating systems and verify that your system has sufficient resources to handle the requirements of both systems.


32-bit Support for KVM on CentOS 6

Whilst previous versions of CentOS supported KVM on both 32-bit and 64-bit systems, as of CentOS 5.4 support for KVM virtualization is only available for 64-bit (x86_64 architecture) versions of the operating system.

Preparing CentOS 6 for KVM Virtualization

Unlike Xen, it is not necessary to run a special version of the kernel in order to support KVM. As a result KVM support is already available for use with the standard kernel via the installation of a KVM kernel module, thereby negating the need to install and boot from a special kernel.

To avoid conflicts, however, if a Xen enabled kernel is currently running on the system, reboot the system and select a non-Xen kernel from the boot menu before proceeding with the remainder of this chapter.

The tools required to setup and maintain a KVM based virtualized system are not installed by default unless specifically selected during the CentOS 6 operating system installation process. To install KVM from the command prompt, execute the following command in a terminal window with root privileges:

yum install kvm virt-manager libvirt

If the installation fails with a message similar to the following then it is likely that you are attempting to install KVM on a 32-bit system, or a 64-bit system running a 32-bit version of CentOS 6:

Error: libvirt conflicts with kvm

Once the installation of KVM is complete, close any applications that are running and reboot the system.

Verifying the KVM Installation

Once the system has restarted after the reboot it is worthwhile checking that the installation worked correctly before moving forward. When KVM is installed and running, two modules will have been loaded into the kernel. The presence or otherwise of these modules can be verified in a terminal window by running the following command:

su -
lsmod | grep kvm 

Assuming that the installation was successful the above command should generate output similar to the following:

# lsmod | grep kvm
kvm_intel              50412  0
kvm                   305113  1 kvm_intel

Note that if the system contains an AMD processor the kvm module will likely read kvm_amd rather than kvm_intel.

The installation process should also have configured the libvirtd daemon to run in the background. Once again using a terminal window with super user privileges, run the following command to ensure libvirtd is running:

# /sbin/service libvirtd status
libvirtd (pid  2958) is running...

If the process is not running, it may be started as follows:

/sbin/service libvirtd start

Finally, run the virt-manager tool by selecting the Applications -> System Tools -> Virtual Machine Manager menu. When loaded, the manager should appear as illustrated in the following figure:


The CentOS 6 virtual machine manager


If the QEMU entry is not listed, select the File -> Add Connection menu option and in the resulting dialog select the QEMU/KVM hypervisor before clicking on the Connect button:


Adding a connection to a CentOS 6 KVM Hypervisor


If the manager is not currently connected to the virtualization processes, right click on the entry listed and select Connect from the popup menu.

In theory the system is now ready to create virtual machines into which guest operating systems may be installed and run. Before taking that step, it is worth spending some time in the next chapter talking about virtual networks and network bridges.


You are reading a sample chapter from the CentOS 6 Essentials Essentials book.

Purchase a copy of the fully updated CentOS 8 edition in eBook ($24.99) or Print ($36.99) format

CentOS 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 260 pages. Learn more...

Buy Print Preview Book



PreviousTable of ContentsNext
Configuring a CentOS 6 Postfix Email ServerCreating a CentOS 6 KVM Networked Bridge Interface