18th October 2007

Debian and KVM virtual machine

Tags : , , ,

posted in Configuration |

I want to play with my brand new Intel Q6600 Core2Quad an Xen 3.1. But IDE chip vt8237s is not supported by 2.6.18 linux kernel. There is a hack to correct this but it's quite ugly.

So why not try KVM ? Amazing !

First, install userspace things :

%  apt-get install kvm qemu

Load Intel VT support :

% modprobe kvm-intel

Create a new disc image in CoW (Copy on Write) mode :

% qemu-img create disk.cow 5G

Start KVM with 512MB Ram and Debian 4.0 install CD :

% kvm -hda disk.cow -cdrom /path/debian-40r1-i386-businesscard.iso -boot d -m 512

Just install minimal Debian, and start again without CD option :

%  kvm -hda disk.cow -m 512

Basic configuration is automatic. Guest system (not so guest, it's KVM) get an IP address by DHCP. That's KVM/QEMU default userspace routing. I don't like it.

I just have one NIC and i must play with TUN/TAP virtual NIC to get ethernet bridge to work.

We need tunctl from uml-utilities package :

% apt-get install uml-utilities

Stop networking stuff :

% /etc/init.d/network stop

And change /etc/network/interfaces like this :

auto lo eth1 tap10 br0

iface lo inet loopback

iface tap10 inet manual
  pre-up tunctl -b -u denis -t tap10
  pre-up ifconfig tap10 up
  post-down tunctl -d tap10

iface br0 inet static
  bridge_ports eth1 tap10
  bridge_maxwait 0
  address 192.168.0.1
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.10

iface eth1 inet manual

Configuring loopback then eth1. Then create tap10 (tap0 used with OpenVPN here) and we bridge eth1 and tap10 and give an IP addresse to the bridge interface. eth1 and tap10 are now physically connected to a virtual hub. Now start kvm with :

% kvm -hda disk.cow -m 512 -net nic -net tap,ifname=tap10

In the guest /etc/network/interfaces we have :

iface eth0 inet static
  address 192.168.0.200
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.10

Done !

This entry was posted on Thursday, October 18th, 2007 at 4:17 pm and is filed under Configuration. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

There is currently one response to “Debian and KVM virtual machine”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On November 27th, 2007, Matthew Clark said:

    Just what I needed! I found *many* articles on the ‘net about how to get TUN/TAP working with QEMU, and nearly all of them involved several steps containing scripts and misc changes to the host system. None of them worked for me. Your article was very simple, and provides exactly what I wanted. Thanks!

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image