Date: 09.04.2020
KVM (Kernel Based Virtual Machine) stands out as a powerful, open-source solution that seamlessly integrates with Linux. It offers a cost-effective and efficient way to virtualize your systems without the need for additional licensing costs. In this guide, we’ll walk you through the process of installing KVM, migrating VMware virtual machines to KVM, creating bridge interfaces, and managing KVM virtual machines. By the end, you’ll be well on your way to harnessing the full potential of KVM for your virtualization needs.
Getting Started with KVM
Step 1: Install KVM
- Start by installing your machine with the 64-bit version of EL5.
- Register your machine with Red Hat using the
rhn_register
command. - Enable virtualization entitlement for your system in RHN (Red Hat Network).
- Install the KVM package and related components:
# yum install kvm
# yum install virt-manager libvirt libvirt-python python-virtinst
Migrating VMware Virtual Machines to KVM
Migrating your existing VMware virtual machines to KVM is a breeze:
- Log in to your VMware server.
- Create a single VMDK image with
vmware-diskmanager
.For example:
# vmware-vdiskmanager -r path_to_vmware_virtualmachine.vmdk -t 0 destination_file_vmware.vmdk
- Copy the image to your KVM server.
- Convert the image to a KVM-supported format using
qemu-img
:
# qemu-img convert destination_file_vmware.vmdk -O qcow2 kvm_supported.img
Setting Up Bridge Interfaces for Networking
To efficiently manage your virtual machines, it’s essential to create bridge interfaces for sharing network cards. This step assumes that you have two NICs (Network Interface Cards) in your server and require bonding along with bridging:
Create a bridge interface. Edit the file /etc/sysconfig/network-scripts/ifcfg-br0
:
DEVICE=br0
ONBOOT=yes
TYPE=Bridge
IPADDR=<ip_address>
NETMASK=<netmask>
GATEWAY=<gateway>
- Configure the bond interface. Edit the file
/etc/sysconfig/network-scripts/ifcfg-bond0
:
DEVICE=bond0
BRIDGE=br0
ONBOOT=yes
- Configure
eth0
andeth1
. Edit the file/etc/sysconfig/network-scripts/ifcfg-eth0
:
DEVICE=eth0
MASTER=bond0
SLAVE=yes
ONBOOT=yes
- Change bonding to
active-backup
mode. Edit the/etc/modprobe.conf
file:
options bond0
miimon=100
mode=active-backup
- Restart the network interface and check the bridge status with:
# brctl show
Creating KVM Virtual Machines
You can create KVM virtual machines using either the command line or the virt-manager
application:
- To create a virtual machine with
virt-manager
, open the application, click “Create New,” and select “QEMU Hypervisor.” During disk selection, choose the path to the converted VMware image. Once completed, your virtual machine is ready for use.
Registering Virtual Machines with Red Hat
Registering your KVM virtual machines with Red Hat can save you valuable licenses:
- Enable network tools entitlement in RHN.
- Install the package
rhn-virtualization-host
on your core machine:
# yum install rhn-virtualization-host
- Enable virtualization under the properties of your host in RHN.
- Execute the following commands on your host machine:
# rhn_check
# rhn-profile-sync
- Log in to your virtual machine and use
rhn_register
. It will now be registered as a virtual machine under the core license.
With these steps, you’ll be fully equipped to leverage KVM for your virtualization needs.
Leave a Reply