Installing and configuring a KVM
This recipe covers the installing of virtualization tools and packages on RHEL 7.
By default, a RHEL 7 system doesn't come with a KVM or libvirt preinstalled. This can be installed in three ways:
- Through the graphical setup during the system's setup
- Via a kickstart installation
- Through a manual installation from the command line
For this recipe, you should know how to install packages using yum, and your system should be configured to have access to the default RHEL 7 repository (refer to Chapter 8, Yum and Repositories, for more information), which is required for the packages that we will use.
Alternatively, you could install packages from the installation media using rpm
, but you'll need to figure out the dependencies yourself.
Check the dependencies of an rpm
using the following command:
This will output a list of binaries, libraries, and files that you need installed prior to installing this package.
Check which package contains these files through this command:
As you can imagine, this is a tedious job and can take quite some time as you need to figure out every dependency for every package that you want to install in this way.
To install a KVM, you will require at least 6 GB of free disk space, 2 GB of RAM, and an additional core or thread per guest.
Check whether your CPU supports a virtualization flag (such as SVM or VMX). Some hardware vendors disable this in the BIOS, so you may want to check your BIOS as well. Run the following command:
Alternatively, you can run the following command:
Check whether the hardware virtualization modules (such as kvm_intel
and kvm
) are loaded in the kernel using the following command:
We'll look at the three ways of installing a KVM onto your system.
This way of installing a KVM is generally done once the base system is installed by some other means. You need to perform the following steps:
- Install the software needed to provide an environment to host virtualized guests with the following command:
The installation of these packages will include quite a lot of dependencies.
- Install additional utilities required to configure
libvirt
and install virtual machines by running this command: - By default, the
libvirt
daemon is marked to autostart
on each boot. Check whether it is enabled by executing the following command: - If for some reason this is not the case, mark it for autostart by executing the following:
- To manually stop/start/restart the
libvirt
daemon, this is what you'll need to execute:
Installing a KVM during kickstart offers you an easy way to automate the installation of KVM instances. Perform the following steps:
- Add the following package groups to your kickstarted file in the
%packages
section: - Start the installation of your host with this kickstart file.
Graphical setup during the system's setup
This is probably the least common way of installing a KVM. The only time I used this was during the course of writing this recipe. Here's how you can do this:
- Boot from the RHEL 7 Installation media.
- Complete all steps besides the Software selection step.
- Go to Software Selection to complete the KVM software selection.
- Select the Virtualization host radio button in Base Environment, and check the Virtualization Platform checkbox in Add-Ons for Selected Environment:
- Finalize the installation.
- On the Installation Summary screen, complete any other steps and click on Begin Installation.