{"id":1069,"date":"2011-02-21T12:16:47","date_gmt":"2011-02-21T10:16:47","guid":{"rendered":"http:\/\/tom.scholten.nu\/weblog\/?p=1069"},"modified":"2011-02-21T13:44:45","modified_gmt":"2011-02-21T11:44:45","slug":"over-to-kvm","status":"publish","type":"post","link":"https:\/\/tom.scholten.nu\/weblog\/2011\/02\/21\/over-to-kvm","title":{"rendered":"Over to KVM"},"content":{"rendered":"<p><wpg2>3270<\/wpg2>This weekend, after an earlier failed attempt, I&#8217;ve managed to change one of the servers to <a href=\"http:\/\/www.linux-kvm.org\/\">KVM<\/a> as virtual machines platform. The first server is done and many will follow. Besides stability my main focus was manageability, the old platform ran (or runs, as not all are transferred yet) on VMware Server. A nice free product but only manageable from Windows as a platform and even on there it became worse every month. KVM ensures management using VNC, command-line or even webinterfaces and with that is more platform independent.<br \/>\nBesides that KVM offers the ability to better virtualisation per virtual machine and is also more lightweight in use. The only issue I&#8217;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&#8217;t give a workable\/performing virtual machine. Testing an XP one did work, w2k8 still to be determined. At least the FreeBSD&#8217;s and Linux hosts work more than fine &#8211; but those are obviously the production ones. Windows was fine for testing, but we&#8217;ll leave it at that \ud83d\ude42<\/p>\n<p>Below more information on my transition, despite being documented all over the internet I&#8217;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.<br \/>\n<!--more--><\/p>\n<p>Setup<\/p>\n<ul>\n<li>Hetzner EQ host (8 GB RAM, 8 Core)\n<li>Debian\n<li>KVM (libvirt, qemu)\n<\/ul>\n<p>Linux host<br \/>\n* Install the required packages<br \/>\n<code>aptitude install kvm libvirt-bin virt-manager qemu uml-utilities vncserver<\/code><br \/>\n* Configure the networks (I&#8217;m not using the &#8216;default&#8217; shared network) in <em>\/etc\/network\/interfaces<\/em><br \/>\n* Note that whatever you currently have on &#8216;eth0&#8217; should be moved to &#8216;br0&#8217; &#8211; I&#8217;ve also included some of the other Hetzner specific example lines!<br \/>\n<code># device: eth0 (physical Hetzner interface)<br \/>\nauto  eth0<br \/>\niface eth0 inet manual<\/p>\n<p># Bridged eth0<br \/>\nauto  br0<br \/>\niface br0 inet static<br \/>\n  address   1.2.3.4<br \/>\n  netmask   255.255.255.0<br \/>\n  gateway   1.2.3.127<\/p>\n<p>  # iptables<br \/>\n  pre-up iptables-restore &lt; \/etc\/iptables.rules<\/p>\n<p>  # default route to access subnet (hetzner)<br \/>\n  up route add -net 1.2.3.0 netmask 255.255.255.0 gw 1.2.3.4 br0<\/p>\n<p>  # Virtual subnet hosts routing<br \/>\n  up ip addr add 5.6.7.8\/255.255.255.240 dev br0<\/p>\n<p>  bridge_ports eth0<br \/>\n  bridge_stp off<br \/>\n  bridge_fd 0<br \/>\n  bridge_maxwait 0  <\/p>\n<p># device: tap0 (virtual \/ virtual host-only interface)<br \/>\nauto tap0<br \/>\niface tap0 inet static<br \/>\n  address 192.168.10.1<br \/>\n  netmask 255.255.255.0<br \/>\n  tunctl_user uml-net<\/p>\n<p># Bridged tap0<br \/>\nauto  br1<br \/>\niface br1 inet static<br \/>\n  address 192.168.10.1<br \/>\n  netmask 255.255.255.0<\/p>\n<p>  bridge_ports tap0<br \/>\n  bridge_stp off<br \/>\n  bridge_fd 2.5<\/code>\n<\/ul>\n<p>* Restart your network (\/etc\/init.d\/networking restart)<br \/>\n* Also make sure that your IP-forwarding is into place (\/etc\/sysctl.conf \/etc\/sysctl.d\/* &#8211; google for sysctl and forwarding)<br \/>\n* Ensure your KVM modules are loaded (lsmod)<\/p>\n<p>For the real part you have to decide which way to go. As Richard (<a href=\"http:\/\/blog.mosibi.nl\/?p=382\">Mosibi&#8217;s blog<\/a>) pointed out you can use vmware2libvirt for this but somehow this wouldn&#8217;t go right on Debian. Also I wasn&#8217;t too keen on just transferring everything over. I ended up configuring everything using VNC (server) and virt-manager.<\/p>\n<p>Per virtual machine migration steps<br \/>\n* Source: \/vms\/old.machine.dir<br \/>\n* Target: \/kvms\/machine.dir<br \/>\n* Install ISO&#8217;s: \/vms\/iso<br \/>\n* First I migrated my old virtual disks, mind that I had VMware &#8216;split&#8217; into 2 GB chunks, if this isn&#8217;t your setup skip the vmware-vdiskmanager command<br \/>\n<code>cd \/vms\/old.machine.dir<br \/>\nvmware-vdiskmanager -r old.machine.vmdk -t 0 \/kvms\/machine.dir\/old.machine.vmdk<br \/>\ncd \/kvms\/machine.dir<br \/>\nkvm-img convert old.machine.vmdk -O qcow2 machine.qcow2<\/code><br \/>\n* 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)<br \/>\n* When asked I configured the server as you would normally do<\/p>\n<ul>\n<li>Architecture x86_64 \/ hvm \/ kvm\n<li>Select to correct OS type (obviously)\n<li>Use the source ISO as boot device (see hint on FreeBSD machines below)\n<li>Configure a single network interface (the bridge one, using the &#8216;default&#8217; network adapter broke libvirt on my machine)\n<li>Complete the other questions\n<\/ul>\n<p>* 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 &#8216;Fixit&#8217; 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 &#8217;em&#8217; devices to &#8216;ed&#8217; ones!<br \/>\n* 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.<br \/>\n* From the commandline run &#8216;virsh edit machine.dir&#8217; 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 \ud83d\ude42<br \/>\n* Example for Linux machine (for FreeBSD replace model type with ne2k_pci, for Windows use rtl8139 or virtio after installing virtio drivers)<br \/>\n<code>    &lt;interface type='bridge'&gt;<br \/>\n      &lt;mac address='00:01:23:45:67:8a'\/&gt;<br \/>\n      &lt;source bridge='br0'\/&gt;<br \/>\n      &lt;model type='virtio'\/&gt;<br \/>\n    &lt;\/interface&gt;<br \/>\n    &lt;interface type='bridge'&gt;<br \/>\n      &lt;mac address='00:01:23:45:67:8a'\/&gt;<br \/>\n      &lt;source bridge='br1'\/&gt;<br \/>\n      &lt;model type='virtio'\/&gt;<br \/>\n    &lt;\/interface&gt;<\/code><br \/>\n* Now you can run your server, either using the buttons in virt-manager or by using &#8216;virsh start machine.dir&#8217;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3270This weekend, after an earlier failed attempt, I&#8217;ve managed to change one of the servers to KVM as virtual machines platform. The first server is<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-1069","post","type-post","status-publish","format-standard","hentry","category-algemeen-en"],"_links":{"self":[{"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/posts\/1069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/comments?post=1069"}],"version-history":[{"count":2,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/posts\/1069\/revisions"}],"predecessor-version":[{"id":1077,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/posts\/1069\/revisions\/1077"}],"wp:attachment":[{"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/media?parent=1069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/categories?post=1069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.scholten.nu\/weblog\/wp-json\/wp\/v2\/tags?post=1069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}