Virtualization with KVM under Redhat Linux, Migrate VMware virtual images to KVM

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 and eth1. 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.


Posted

in

,

by

Comments

5 responses to “Virtualization with KVM under Redhat Linux, Migrate VMware virtual images to KVM”

  1. […] This post was mentioned on Twitter by Fynali Iladijas, Arun Natarajan S. Arun Natarajan S said: Virtualization with KVM under Redhat Linux, Migrate VMware virtual images to KVM: KVM (Kernel Based Virtual Machin… http://bit.ly/9RE7OP […]

  2. yogesh Avatar

    Hi Arun,

    Thanks for nice explanation. Does it also apply to VMWare guest images of Windows XP (x86) on Windows-7 (x64) host installation? Whats the purpose of the bonding? Under single NIC can one use NAT instead of bridging?

    Thanks,
    Yogesh

    1. Arun N S Avatar

      Hi Yogesh,
      Yes you can convert the vmware images(VMDK) from a windows host as well, Bonding is used if you have multiple network interfaces doing failover/loadbalancing etc. It will simply work with bridging or nating on a single interface. Instead of creating bridge with bond interface, do it with the physical interface (like eth0 or eth1).
      $ cat /etc/sysconfig/network-scripts/ifcfg-br0

      DEVICE=br0
      ONBOOT=yes
      TYPE=Bridge
      IPADDR=11.11.11.11
      NETMASK=255.0.0.0
      GATEWAY=1.1.1.1

      – Configure the physical interface:
      $ cat /etc/sysconfig/network-scripts/ifcfg-eth0

      DEVICE=eth0
      BRIDGE=br0
      ONBOOT=yes

      ./arun

  3. surya Avatar
    surya

    Hi Arun,
    I have a doubt regarding virtualisation.can i use VMware and KVM in a single host? will it work without any problems?

    Thanks,
    Surya

    1. Arun N S Avatar

      Not sure, might work. try with vmware player/server and KVM on a 64 bit OS with full virtualization. But might have reliability issues, not recommended for production use. Can you please let me know the hardware specification?

      In my opinion it is not a good idea to run both in the same machine. You could convert the vmware images to raw format and use it with KVM, or the other way around.

      ./arun

Leave a Reply

Your email address will not be published. Required fields are marked *