Besides that KVM offers the ability to better virtualisation per virtual machine and is also more lightweight in use. The only issue I’ve encountered so far is a test-windows7 install which proved not to work on KVM. It did on qemu but locked out one processor on 100% use and even that wouldn’t give a workable/performing virtual machine. Testing an XP one did work, w2k8 still to be determined. At least the FreeBSD’s and Linux hosts work more than fine – but those are obviously the production ones. Windows was fine for testing, but we’ll leave it at that 🙂
Below more information on my transition, despite being documented all over the internet I’ve had to visit multiple sites to properly deploy and migrate. Even though there are various small things not working (described below) but at least KVM runs and the virtual machines are running very fine and without any 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’