virtualization
How to Setup KVM on Ubuntu Lucid
More than a year ago I wrote an article about Xen on Ubuntu Intrepid with the intention of blaming Ubuntu. I also clearly said, that I wouldn’t use Ubuntu anymore. This article turned out to be the most hit one on my blog. Maybe because the Ubuntu community directly links to it. Then, last Summer I wrote an article about alternatives to Xen, but I decided to wait and stay with Xen on my homeserver in the meantime. (Please keep in mind, all I use this for is for my private setups!). Last week I upgraded my Server’s hardware and also wanted to re-install it.
Xen still hasn’t made it into vanilla Kernel, it might make it into 2.6.34 or .35, but even if it does, I think it’s not even going to be close to being production ready. Plus most distributions release their next version in the next weeks/months and are already frozen, so they definitely will not ship with Xen. Well, the only real alternative is KVM. I didn’t like the idea of using KVM for a long time, but since almost every distribution now features KVM as their virtualization technique, I went with it. I also went with Ubuntu again (yeah blame me!). Why? Because their next release has long-term support, and I won’t have the time to upgrade it in the next 12-18 months. And what shall I say… I like it. Installation was kinda tricky on a software Raid0, but I was installing a development release, 1 week before the first Beta… and in the end it did work.
The server runs KVM now and it runs fast and stable. I have 4 virtual machines on it now. Installation of the guests using virt-installer and/or ubuntu-vm-builder was much easier and ended up with working VMs out of the box, whereas xen-create-image ended up with an unusable image on Intrepid, because the default console never showed up without tweaks. libvirt is also nice if you need it, but I really want to point out, that you can run KVM without libvirt just with the ‘kvm’ command!
I tagged this article ‘How-To’, but there are already many good KVM guides out there so I won’t write yet another one. I’ll just post a few hints to get KVM running with a bridged networking using libvirt.
First of all I removed /etc/libvirt/qemu/networks/default.xml to disable the dnsmasq features of libvirt. Then I created an LVM volume group where I wanted to place my machines at, but you can also use simple images on your filesystem. The next thing I did was setting up a bridge in /etc/network/interfaces:
auto br1
iface br1 inet dhcp
bridge_ports eth1
bridge_stp off
bridge_fd 0
bridge_maxwait 0
You can now simply create your virtual machine with this command:
virt-install -n $hostname -r 512 -c /home/shared/apps/os/ubuntu/lucid-server-amd64.iso --disk path=/dev/virtdisks/bender --network bridge=br1 --vnc --vnclisten=0.0.0.0 --noautoconsole --os-type linux --os-variant ubuntuLucid --accelerate
Now connect to your host using VNC and install as usual. Another way is to use ‘ubuntu-vm-builder’, but I simply didn’t try… Make sure you limit VNC access to localhost in /etc/libvirt/qemu/$hostname.xml after installation if your network is unsecure.
To make your domain autostart on boot use:
virsh autostart $hostname
This will copy the appropriate xml configuration file to /etc/libvirt/qemu/autostart/.
It’s as simple as that. Way easier than patching a kernel for Xen and all these things. I would have really loved to see Xen in vanilla Kernel a year ago or so, but it didn’t happen and KVM works well enough for me by now… plus you have the benefit of a working power-management.
Take care.
2009’s Virtualization Techniques Compared
Hi folks, before we get started a small explanation of my setup and why I want to replace it.
My small home server runs Xen 3.3 with Ubuntu Intrepid, a Debian Xen kernel and the guests on LVM devices. Guest OSs vary from Debian over Solaris to Windows. I built the server last year, but sadly I’m already running out of HDD space and want to upgrade soon. I also want to re-install the Dom0 because Intrepid doesn’t run very well: USB doesn’t work with all devices, there are some bugs in the start-up scripts and I have trouble with the ttys.
A lot has changed since I last fiddled with virtualization so I used this weeks bad weather to compare the current status of all those virtualization systems.
Because there are so many different needs, there are many specialized solutions for desktop and server virtualization. Open-Source, free or commercial ones.
I use VirtualBox on my workstation because it’s free, fast, easy to use and runs very very well. I’ve used the VMware products earlier on Linux and Windows until they became too feature-rich, slow and sometimes even buggy for me. But this post is not about desktop virtualization, it’s about open-source (or free) server virtualization.
VMware Server, VMware ESXi, Microsoft Hyper-V, VirtualBox, Xen and KVM are the ones I’ve tried. There is also Virtuozzo, OpenVZ, UML and so on, but these are more like chroots on steroids. Continue reading to see what I liked and what I didn’t like about them.
help.ubuntu.com links to my blog
I was just comparing the current status of KVM, Xen and some other virtualization techniques when I came across the Ubuntu Help for Xen. The page states that Ubuntu still doesn’t provide a Xen Dom0 Kernel in their latest release, but that doesn’t surprise me becaus Xen still didn’t make it into the official Kernel… maybe because everyone loves KVM that much. But they link you to a blog post which shows how to run Xen on Ubuntu anyhow.
Noticed it? Yes that’s my article. I was really surprised to see a link to my actually pretty provocative article on an Ubuntu site. They could have also linked to bderzhavets article.
So… that’s it for now. I’ll continue comparing virtualization techniques with the help of debian-user-german and will hopefully begin with the reinstallation of my xen host.
How to Run Xen in Ubuntu Intrepid without compiling a Kernel by yourself
Update2: Switch from Xen to KVM. How and why.
Update: Also read my Article about current Virtualization Techniques
I got some strange errors when I tried to run OpenSolaris on Hardy as a HVM domain. These errors were fixed in 3.3, but Ubuntu Hardy doesn’t have Xen 3.3 and there were no backports at that time (don’t know if there are ones now) so I upgraded to Ubuntu Intrepid an then noticed that Canonical has dropped Xen Dom0 support. Great! Why the heck did they drop Xen? Because KVM is cooler? Or because they didn’t want to blame themselves by releasing another totally buggy self-patched Dom0 kernel?
I mean they didn’t even manage to provide a working one later on so the community had to…and thats a LTS release? WTF?
O.K. well… You want Xen 3.3 with it’s improvements? You don’t want to switch the distro? You don’t want to compile on your own? Here’s how I did it with Ubuntu Intrepid:
I used the Xen 3.3 Hypervisor and Utils coming with Intrepid and then stole a Dom0 kernel from Debian. Debian has linux-image-2.6.26-1-xen-amd64 and linux-modules-2.6.26-1-xen-amd64. I installed both packages and by now everything works great.
O.K. I called this post How-To so here comes how to install the Debian packages on Ubuntu. I will only show you how to install them by hand, you could also add the Debian repos to your sources.list and use pinning.
wget http://ftp.de.debian.org/debian/pool/main/l/linux-2.6/linux-modules-2.6.26-1-xen-amd64_2.6.26-10_amd64.deb wget http://ftp.de.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.26-1-xen-amd64_2.6.26-10_amd64.deb sudo dpkg -i linux-modules-2.6.26-1-xen-amd64_2.6.26-10_amd64.deb sudo dpkg -i linux-image-2.6.26-1-xen-amd64_2.6.26-10_amd64.deb wget http://ftp.de.debian.org/debian/pool/main/l/linux-2.6/linux-modules-2.6.26-1-xen-amd64_2.6.26-12_amd64.deb wget http://ftp.de.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.26-1-xen-amd64_2.6.26-12_amd64.deb sudo dpkg -i linux-modules-2.6.26-1-xen-amd64_2.6.26-12_amd64.deb sudo dpkg -i linux-image-2.6.26-1-xen-amd64_2.6.26-12_amd64.deb
Or find the latest using these links: modules kernel
That’s it. There are no other depends. Just reboot. The new kernel should now be the default one. But keep in mind that this is just a workaround.
If I should ever reinstall this Xen-Server: I WILL NOT USE UBUNTU ANYMORE! All these annoying stupid errors… Maybe Debian or CentOS. I mean… I like Ubuntu, it’s a great beginner distro and even lets the nerds control everything they want, but what Canonical delivered the last few months just sucks. All these annoying bugs they added by patching arround: Non-working sound, A buggy KDE4. O.K. you could say that’s all desktop related stuff, but on my server for example I had some very strange XFS errors with the Ubuntu-Server kernel that just disappeared with the (also newer, maybe that’s the point) Debian kernel.
Hi, my name is Chris. I am a wannabe photog, traveler & geek that lives in Hesse, Germany. 