What is KVM?

No comments exist

I first ran across KVM about one year ago.  At first I thought it was the traditional "Keyboard-Video-Mouse" switches that I have been using for many years in data centers.  After listening to KVM in context I soon realized that I was incorrect.  This KVM stands for "Kernel-based Virtual Machine" and runs on most current distributions of Linux.  Kernel-based Virtual Machine

 

What does KVM do?  KVM is an open source alternative to Microsoft Hyper-V, VMWare, and Citrix XenServer (although the base XenServer is now free)  IT runs on many Linux distributions.  I have tested it on Ubuntu and on CentOS.  Below is a quick summary of how to get started using KVM on Ubuntu version 10.x and up.

 

First you need to have compatible hardware. If you have linux running perform the following command.  grep -E 'vmx|svm' /proc/cpuinfo otherwise for Intel based systems

 

  1. Power off the machine completely.
  2. Power on the machine and enter the BIOS by pressing the F1 key during boot.
  3. In the BIOS menu, select Advanced Step → CPU Options.
  4. Confirm that the Intel Virtualization Technology option is Enabled.
  5. Save the setting and exit the BIOS.

 

Now get the libraries for KVM.  sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

 

You need to ensure that your username is added to the group libvirtd:

 

 $ sudo adduser `id -un` libvirtd Adding user '<username>' to group 'libvirtd' ...

 

After this, you need to relogin so that your user becomes an effective member of the libvirtd group. The members of this group can run virtual machines.

 

Create your first Guest OS.

 

The virt-manager tool is a GUI tool used to create and manage KVM guests.

 

Follow these steps to set up a KVM guest using virt-manager. This example installs a SLES 11 (Suse Linux) guest.

 

  1. Start your X11 environment by logging in to your system using the ssh -X command.
  2. Start virt-manager by running the virt-manager command.  This command opens the Virtual Machine Manger window.
  3. Select the first row, which represents the host domain, and click New to create a new guest. This action opens the Virtual Machine Creation window. Click Forward to start entering information about your guest.
  4. In the Virtual Machine Name window, enter a name for your guest. In this example, the virtual machine is named MY_VM1_SLES11. Click Forward.
  5. In the Virtualization Method window, select the virtualization method that you want to use.
    • Select Fully virtualized (paravirtualization is not supported in KVM).
    • Select the processor architecture you want to simulate. This example uses x86_64.
      Note: If you are running KVM on an i686 machine, you cannot simulate the x86_64 architecture.
    • Select kvm for Hypervisor.
    Click Forward.
  6. In the Installation Method window, select your installation method.
    • Select your installation media. This example uses an installation source that is available through an NFS mount so Network Install tree (HTTP, FTP, or NFS) is selected as the installation media
    • Select your OS type. This example is installing a Linux OS so Linux is selected as the OS type
    • Select your OS variant. This example is installing SLES so Suse Linux Enterprise Server is selected as the OS variant
    Click Forward.
  7. Depending on which installation media option you chose, you may need to select an installation source. If you are using the Network PXE boot option, skip this step and go the next step to assign storage.

    If you are using the ISO or CD media, or the network media installation methods, specify the location of your installation media. In this example, the location of the NFS install tree (nfs://xyz.com/nfs_installdir_sles11) is specified in the Installation media URL field. Click Forward.

  8. In the Storage window, assign an existing Block device or select to create an .img File. If you select File, specify its size. Make sure that you allocate enough disk space for your operating system by consulting the operating system's documentation for the minimum amount of disk space needed. In this example, an existing LVM partition, /dev/mapper/MY_VG1-MY_LVM1, from a local disk is assigned. Click Forward.
  9. In the Network window, select Virtual network or Shared physical device.

    If you have not set up a Linux bridge, choose the default Virtual network.

    In this example, Shared physical device is used and br0 (bridge to eth0) is specified. This bridge was configured earlier in the section Configuring the network. Click Forward.

  10. In the Memory and CPU Allocation window, select the maximum and startup memory, and the number of virtual CPUs that the system should have. In this example, the guest is given 2000 MB Max memory, 1200 MB of Startup memory and 2 Virtual CPUs.
    Note: Note that you can dynamically update the two resources while the guest is still running if the new assignment is smaller or equal to the maximum amount allocated.

    Click Forward.

  11. In the Summary window, verify the settings for creating the guest. When you are satisfied, click Finish.

 

Try out KVM!

Leave a Reply