Installation
- install kvm
apt-get install qemu-kvm libvirt-bin
accept dependencies and install
- add normal user to kvm and libvirt groups to allow him to manage your virtual machines
adduser username kvm
adduser username libvirt
Network settings
- set bridge mode(virtual machine will work in the same subnet)
apt-get install bridge-utils
on my server bride-utils has been installed during kvm installation
by default virtual machines use nat mode
- add new interfaces to /etc/network/interfaces
# Bridge interfaces
auto ftp-server
iface ftp-server inet static
address 172.16.0.3
netmask 255.255.255.0
network 172.16.0.0
broadcast 172.16.0.255
gateway 172.16.0.1
interface name can be any,e.g. ftp-server
bridge_ports eth0
assign virtual interface to physical interface
any virtual machine can use this virtual interface with different ip on the same subnet
Managing virtual machines
- install virtinst(for console) or virt-manager(for X)
apt-get install virtinst virt-manager
accept dependencies and install
- Reboot server
- create virtual machine for e.g. CentOs either using virt-install or virt-manager.I prefer virt-manager..
Virt-install.
virt-install –connect qemu:///system -n ftp-pl -r 512 –vcpus=2 -f /vm/ftp-pl/hd.qcow2 -s 85 -c /home/iso/CentOS-6.0-x86_64-netinstall.iso –vnc –noautoconsole –os-type linux –accelerate –network=bridge:ftp-server –hvm
-n “virtual machine name”
-r ” RAM in MB”
–vcpus “nr of CPUs”
-s “space on HD in GB”
-c “iso image for installation”
Below output of this command(in polish)
Uruchamianie instalacji…
Tworzenie pliku pamięci masowej hd.qcow2 | 85 GB 00:00
Tworzenie domeny… | 0 B 00:00
Trwa instalacja domeny. Mozna ponownie polaczyc sie z
konsola, aby ukonczyc proces instalacji.
connect to virtual machine via virt-viewer.
Virt-manager
Virt-manager is very helpfull and easy to use application which allows us to manage our virtual machine from X like Gnome.
KVM is very stable and reliable environment. In my case (DELL 2950, 2 x Xeon) I did not notice any problem however take into account in server environment you should use Debian with KVM without any other services.It should be treated like Esxi or XenServer.
dzbanek 2012-10-12