Building a KVM host on Debian

As a continuing project I always love playing with virtulisation. This is some notes for installing and configuring KVM on Debian. Its mainly for my own reference, but if you find it useful please leave a comment!

1. Create a Debian ‘base system’ and fully update it. I use Debian stable, and a minimal install.

Hardware Requirements for KVM

KVM works best if your processor supports virtulisation extensions. It WILL still work if you dont, but dont expect any decent performance! Installations of virtual hosts are sometimes painfully slow without this!

I like my virtualmachines to get their own proper IP address from my LAN or be configured with a static. For this to work and get past the default NAT setup, you will need to setup a network bridge. Follow the link here: http://wiki.debian.org/BridgeNetworkConnections#Setting_up_your_Bridge on how to set that up.

2. Now you should have a fully patched and updated Debian system, we’re now going to install KVM:
apt-get install qemu-kvm libvirt-bin

Revisiting Virtulization

Its time to revisit virtulization. My home server homer is in dire need of some more diskspace, RAM and general cleaning up. It would probably help if the roles were split across a couple of VM’s. A bit of my development work requires a windows server or 2 and the rest, which is mainly web development is fine with running on Debian.

However, these days homer is showing his age. He is an old Dell, running only a P4 2.8 GHz chip. Hardware vitulization is not supported and previous attempts at running Vmware hasnt worked that well. I think its time to build a new server:

Requirements
1. Its got to be as quiet as possible (currently its in the bedroom, between our desks)
2. Low power consumption
3. Loads of diskspace (main house fileserver for movies) preferably in an LVM or maybe even some kind of RAID.
4. Enough RAM to run a few VM’s for various roles.
5. Low cost – its almost Xmas man!

 

 

Resizing Xen Disk Images

My Xen host was only created with a 4GB partition:

bart:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 4.0G 2.8G 1.1G 73% /
tmpfs 129M 0 129M 0% /lib/init/rw
udev 10M 24K 10M 1% /dev

With hindsight, this was far too small.
If you a using basic ‘file’ based images you can safely resize them:

First of all make sure you create a backup of your current image:
(Make sure that the image is not mounted or running.)

bart:~# cp hd.img backup.img

bart:~# dd if=/dev/zero of=hd.img bs=1M conv=notrunc count=1 seek=8000

This will resize the image to approx 8GB.

Now boot your host and expand the filesystem:

bart:~# resize2fs /dev/sda1
resize2fs 1.40-WIP (14-Nov-2006)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sda1 to 2048256 (4k) blocks.
The filesystem on /dev/sda1 is now 2048256 blocks long.

bart:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 7.7G 2.8G 4.6G 38% /
tmpfs 129M 0 129M 0% /lib/init/rw
udev 10M 24K 10M 1% /dev

:D

Xen Server Setup on Debian Etch

I have spent the morning reading up on Xen details. Im very impressed so far. It seems a great way of doing things. The only thing I am a bit worried about is that the processor in my test rig does not support hyperthreading, so I might not get any performance increase to begin with. However, the plan for the moment is to complete the Debian server and to install 3 guest OS’s: Windows 2000, Windows XP and a Debian server install. At the moment im following this giude : http://shearer.org/MinimalEtchXen It is geared to a nice minimal Etch install so should be perfect for my needs!

Wish me luck!

Dammit. Windows images will NOT run without a VT enabled processor. Anybody got a spare Dual-Core Intel Chip and board lying around spare? ;-)

Xen Thinking

Xen clustering is the way to go. Im thinking of creating a Xen install (Debian) on one of my faster boxes to perform the following roles:

Windows 2000 Server (Game Server)
Debian Linux Server (www, mail, ftp)
Debian Linux Server (internal file & print server)
Windows XP Pro (client test install)

I’ll let you know how I get on! :-)