Skip to content

Recentste berichten

  • After 13 and a bit it’s time for 13!
  • Na 13 en een beetje, komt 13?
  • Dining-out!
  • Lekker eten
  • Special night

Most Used Categories

  • Algemeen (190)
  • Algemeen @en (106)
  • Werk (83)
  • Lekker (eten en drinken) (55)
    • Recepten (8)
  • Motor (36)
  • Trouwen (27)
  • Fiets (25)
Skip to content

tom.scholten.nu

Tom's personal log

Subscribe
  • About me
  • Archief
    • CMS Framework
    • Postfix LDAP Howto
      • Postfix LDAP Howto
      • Postfix LDAP Howto v2.0 part two
    • Scroller.txt
  • Archive
  • aXBo – Testing
  • Cookie Policy
  • iPad
  • iPad
  • iPhone
    • iPhone (1.0)
      • Modem/proxy usage
    • iPhone (2.0)
  • iPhone
  • LoBySS
  • LoBySS
  • Music
  • Muziek
    • Never ending story (Limahl)
    • SnoWMusic
    • The Load out / Stay (just a little bit longer)
  • OSX Tools and Stuff
  • OSX Tools and Stuff
  • Over mij
  • Postfix LDAP Howto v2.1
  • Postfix LDAP Howto v2.1
  • Postfix MySQL howto v1.0
  • Recipes
  • Speedtouch SIP spoof (716)
  • WPG2
  • Wiki
  • Home
  • 2011
  • februari
  • 21
  • Over naar KVM

Over naar KVM

Tom21 februari 201121 februari 2011

3270Dit weekend, na een eerder mislukte poging, is het dan toch gelukt om te switchen naar KVM als platform voor virtual machines. De eerste server is over en velen zullen volgen. Naast stabiliteit was managability een van de speerpunten, het oude platform draaide (maar ook draait, nog niet alle servers zijn over) op VMware Server. Een goed gratis product maar alleen te beheren met een Windows platform en zelfs daar begon het steeds meer kuren te vertonen. KVM voorziet in beheer via zowel VNC, command-line of als je wilt web-interfaces en is daarmee beheersplatform onafhankelijk.
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’

Post navigation

Previous: Multilingual blogging
Next: Over to KVM

Related Posts

Na 13 en een beetje, komt 13?

31 december 201231 december 2012 Tom

Je hebt van die momenten …

15 november 201231 december 2012 Tom

EuroBSDcon : de Warsaw editie

22 oktober 201231 december 2012 Tom
Copyright All Rights Reserved | Theme: BlockWP by Candid Themes.

Warning: Undefined array key "ltasurl" in /var/www/html/weblog/wp-content/plugins/flash-video-player/flash-video-player.php on line 96

Warning: Trying to access array offset on null in /var/www/html/weblog/wp-content/plugins/flash-video-player/flash-video-player.php on line 96