I would like to create several Ubuntu Server Virtual Machines using KVM to test and use. How do I create Virtual Machines using KVM?
2 Answers
If you do not already have KVM installed, you will need to do that. There is a kvm
metapackage in the repos.
sudo apt-get install kvm
To create VMs the easy way, use virt-manager (available in the repos). It provides a nice GUI to walk you through it.
sudo apt-get install virt-manager
Keep in mind you can use virt-manager either on your local KVM server, or on a remote one. Once you have it fired up and pointed to the right KVM server, just click the "Create New Virtual Machine" button. The rest of it is fairly self-explanatory.
Also, if you want to use a bridged interface for KVM, follow my guide here: http://john.wesorick.com/2012/01/setting-up-bridged-network-interface.html
Bridged mode works better for any kind of networking on the virtual machine.
Tis site has the answer Click Here
Below is the text from that site:
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:
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
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
Configure a bridge (Debian/Ubuntu or Red Hat/Fedora) to use a single network interface for all your virtual machines.
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
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 hope that it will help.
Source: http://acidborg.wordpress.com