Daarnaast biedt KVM de mogelijkheid tot betere virtualisatie per virtuele machine en is ‘lichter’ in het gebruik. Enige tot nu toe gevonden issue is dat een test-windows7 installatie niet blijkt te werken op KVM. Draaien op qemu werkt wel maar ‘locked’ een processor op 100% en gaf zelfs dan geen enkele performance binnen de virtual machine zelf. Een XP machine testen werkte wel. Testen van w2k8 staat nog op de lijst. In elk geval draaien de FreeBSD’s en Linux hosts meer dan prima – dat zijn ook de productiemachines natuurlijk. Windows was prima om te testen maar daar blijft het dan ook bij 🙂
Hieronder meer informatie over mijn transitie, hoewel vaker beschreven op het internet heb ik meerdere sites moeten bezoeken om een en ander goed te deployen en te migreren. Dan nog zijn er kleine dingen die niet werken zoals elders beschreven maar in elk geval draait KVM en de virtuele machines zeer goed en zonder verdere issues.
Setup
- Hetzner EQ host (8 GB RAM, 8 Core)
- Debian
- KVM (libvirt, qemu)
Linux host
* Install the required packages
aptitude install kvm libvirt-bin virt-manager qemu uml-utilities vncserver
* Configure the networks (I’m not using the ‘default’ shared network) in /etc/network/interfaces
* Note that whatever you currently have on ‘eth0’ should be moved to ‘br0’ – I’ve also included some of the other Hetzner specific example lines!
# device: eth0 (physical Hetzner interface)
auto eth0
iface eth0 inet manual
# Bridged eth0
auto br0
iface br0 inet static
address 1.2.3.4
netmask 255.255.255.0
gateway 1.2.3.127
# iptables
pre-up iptables-restore < /etc/iptables.rules
# default route to access subnet (hetzner)
up route add -net 1.2.3.0 netmask 255.255.255.0 gw 1.2.3.4 br0
# Virtual subnet hosts routing
up ip addr add 5.6.7.8/255.255.255.240 dev br0
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
# device: tap0 (virtual / virtual host-only interface)
auto tap0
iface tap0 inet static
address 192.168.10.1
netmask 255.255.255.0
tunctl_user uml-net
# Bridged tap0
auto br1
iface br1 inet static
address 192.168.10.1
netmask 255.255.255.0
bridge_ports tap0
bridge_stp off
bridge_fd 2.5
* Restart your network (/etc/init.d/networking restart)
* Also make sure that your IP-forwarding is into place (/etc/sysctl.conf /etc/sysctl.d/* – google for sysctl and forwarding)
* Ensure your KVM modules are loaded (lsmod)
For the real part you have to decide which way to go. As Richard (Mosibi’s blog) pointed out you can use vmware2libvirt for this but somehow this wouldn’t go right on Debian. Also I wasn’t too keen on just transferring everything over. I ended up configuring everything using VNC (server) and virt-manager.
Per virtual machine migration steps
* Source: /vms/old.machine.dir
* Target: /kvms/machine.dir
* Install ISO’s: /vms/iso
* First I migrated my old virtual disks, mind that I had VMware ‘split’ into 2 GB chunks, if this isn’t your setup skip the vmware-vdiskmanager command
cd /vms/old.machine.dir
vmware-vdiskmanager -r old.machine.vmdk -t 0 /kvms/machine.dir/old.machine.vmdk
cd /kvms/machine.dir
kvm-img convert old.machine.vmdk -O qcow2 machine.qcow2
* With the new disk in place I created a new virtual machine using virt-manager (start VNCserver, export your display, start virt-manager, connect to the VNC server)
* When asked I configured the server as you would normally do
- Architecture x86_64 / hvm / kvm
- Select to correct OS type (obviously)
- Use the source ISO as boot device (see hint on FreeBSD machines below)
- Configure a single network interface (the bridge one, using the ‘default’ network adapter broke libvirt on my machine)
- Complete the other questions
* As soon as the machine started I immediately aborted for the non-FreeBSD systems. For the FreeBSD systems I dove into the install ISO and used ‘Fixit’ to mount my disks (from VMware /dev/da to KVM /dev/ad (as VMware uses SCSI and KVM uses IDE) in /etc/fstab. Also on FreeBSD you might want to change (while in fixit) the /etc/rc.conf and /etc/pf.conf (for instance) on the network device name. I went with the ne2k_pci driver so changed all my ’em’ devices to ‘ed’ ones!
* After stopping the virtual machine KVM will switch automatically from CD-boot to HD-boot which is good, but now that it is stopped we can change a few values.
* From the commandline run ‘virsh edit machine.dir’ and add both bridges (to your liking). You can also change the mac-addresses of them or edit your virtual machine (bios) UUID which might come in handy when installing various OS 🙂
* Example for Linux machine (for FreeBSD replace model type with ne2k_pci, for Windows use rtl8139 or virtio after installing virtio drivers)
<interface type='bridge'>
<mac address='00:01:23:45:67:8a'/>
<source bridge='br0'/>
<model type='virtio'/>
</interface>
<interface type='bridge'>
<mac address='00:01:23:45:67:8a'/>
<source bridge='br1'/>
<model type='virtio'/>
</interface>
* Now you can run your server, either using the buttons in virt-manager or by using ‘virsh start machine.dir’