Jaime Frutos Morales's blog

18/02/2010

How to create virtual machines using KVM (Kernel-based Virtual Machine)

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 14:24

Description: KVM is a virtualization infrastructure included in the Linux kernel since 2.6.20 . Although it supports some kinds of paravirtualization, I’m going to explain how to create virtual machines /also called guests) using its full virtualization support.

Steps:

  1. Check if your processor supports full virtualization (if either vmx or svm appears as a flag, then your processor supports it): egrep '(vmx|svm)' --color=always /proc/cpuinfo
  2. Install the packages needed:
    • Debian/Ubuntu: apt-get install kvm libvirt0 python-libvirt python-virtinst
    • Red Hat/Fedora: yum install kvm libvirt libvirt-python python-virtinst
  3. Configure a bridge (Debian/Ubuntu or Red Hat/Fedora) to use a single network interface for all your virtual machines.
  4. Create the virtual machine (a RHEL 5 virtual machine in this example): virt-install --name=guest_name --arch=x86_64 --vcpus=1 --ram=512 --os-type=linux --os-variant=rhel5 --hvm --connect=qemu:///system --network bridge:br0 --cdrom=/var/lib/libvirt/images/rhel5-x86_64.iso --disk path=/mnt/virtual_machines/guest_name.img,size=20 --accelerate --vnc --noautoconsole --keymap=es
    Explanation of the params:

    • name: name of the guest.
    • arch: architecture of the guest.
    • vcpus: number of CPUs assigned to the guest.
    • ram: MB of RAM assigned to the guest.
    • os-type and os-variant: available options can be checked using man virt-install.
    • hvm: use full virtualization.
    • connect: connect to the hypervisor.
    • network bridge: the bridge to use for the guest.
    • cdrom: the ISO of the operating system to install.
    • disk path=x,size=y: path and size of the image file for the guest.
    • accelerate: make use of the KVM acceleration capabilities if available.
    • vnc: export a virtual console over VNC to the guest.
    • noautoconsole: Don’t automatically try to connect to the guest console.
    • keymap: keyboard layout for the VNC console
  5. Use a VNC client to connect to the guest (port 5900 or 5901 if you already have a VNC server listening on port 5900) and install the operating system.

I’ll write another post soon explaining all the operations which can be done with KVM virtual machines using virsh.

Advertisements

1 Comment

  1. […] more: How to create virtual machines using KVM (Kernel-based Virtual … Posted in: Kernels, Virtualization ADD […]

    Pingback by How to create virtual machines using KVM (Kernel-based Virtual … | Linux Affinity — 18/02/2010 @ 15:34


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Create a free website or blog at WordPress.com.

%d bloggers like this: