Home
22 December 2005 @ 10:56 am
Xen  
Been trying to figure out Xen and get it running reliably.

So far....

Also this is using the binary files for Xen, once I have a spare box free I'll modify this to include patching the kernel so you don't have to reboot into a Xen kerenl.

Decide where the images will live. (/opt /home /var, whatever)

mkdir -p /opt/xen/bin

cd /opt/xen/bin

wget http://bits.xensource.com/Xen/latest/xen-3.0.0-install-x86_32.tgz

untar the file

./install.sh

update-rc.d xend defaults

update-rc.d xendomains defaults

mv /lib/tls /lib/tls.disabled <-- trying to find a way around this, maybe it's a waste of time though...

add to /boot/grub/menu.lst

title Xen 3.0 / XenLinux 2.6
kernel /boot/xen-3.0.gz dom0_mem=262144
module /boot/vmlinuz-2.6-xen0 root=/dev/hda1 ro console=tty0

apt-get install bridge-utils iproute debootstrap

mkdir -p /opt/xen/domains/vm01
dd if=/dev/zero of=/opt/xen/domains/vm01/diskimage bs=1024k count=1024 (count=1024 assumes 1 GB drive, adjust accordingly)
dd if=/dev/zero of=/opt/xen/domains/vm01/swapimage bs=1024k count=128 (128 MB swap adjust accordingly)
mkfs.ext3 /opt/xen/domains/vm01/diskimage
mkswap /opt/xen/domains/vm01/swapimage
mkdir /mnt/disk
mount -o loop /opt/xen/domains/vm01/diskimage /mnt/disk
debootstrap --arch i386 sarge /mnt/disk http://ftp.us.debian.org/debian
chroot /mnt/disk /bin/bash
cd /etc; vi hostname hosts resolv.conf

create fstab
/dev/sda1 / ext3 errors=remount-ro 0 1
/dev/sda2 none swap sw 0 0
proc /proc proc defaults 0 0

logout and umount

configure Xen machine
cat > /etc/xen/vm01.cfg
kernel = "/boot/vmlinuz-2.6.12.6-xenU"
memory = 96
name = "vm01"
dhcp = "dhcp"
disk = [ 'file:/opt/xen/domains/vm01/diskimage,sda1,w','file:/opt/xen/domains/vm01/swapimage,sda2,w' ]
root = "/dev/sda1 ro"

start the Xen machine
xm create vm01 -c (-c connects a console, if omitted use xm console vm01)

login as root (no password set yet)

passwd
apt-setup or base-config
apt-get update && apt-get upgrade


This is not the easiest, or even best way to do this but I've only been looking at it for about 2 hours and this is what I have so far.

UPDATE
disk = [ 'phy:/dev/hdX,hda1,w', 'phy:/dev/hdY,hda2,w' ] <-- partitions instead of files guess LVM would run in a similiar manner

REFERENCES

http://julien.danjou.info/xen.html
 
 
10 December 2005 @ 10:30 pm
Upcoming projects...

Terminal Server

Dansguardian & ClamAV (Content filtering and AV)

Reconfigure network services and organization (SSL CA, etc...)

Jabber Server

COMPLETED

Unslung; got XBMC media shares off samba and on to XBMSP (granted wide open udp is probably more of a security risk than weak passworded samba but it is all internal and if someone really wants to steal/delete my movies/mp3's that bad they can... might look at removing samba from the nslu2
wireless running openwrt w/multiple bridges
Like WiKID but the open version does not support J2ME clients so using my cell phone as a fob won't work, might be worth setting up the commercial trial iso on a VM but I'll come back to this later
 
 
27 November 2005 @ 08:53 pm
Basic directions for installing qemu with kernel acceleration and bridged networking. For image space I recommend an LVM configuration. (The steps for checkinstall are somewhat optional. I've had mixed results using this.)

Go to http://fabrice.bellard.free.fr/qemu/download.html

Download qemu source (At the time of writing I used qemu-0.7.2.tar.gz)
Download kqemu binary (At the time of writing I used kqemu-0.7.2.tar.gz)

Install your kernel headers.
sudo apt-get install linux-headers-$(uname -r)

Install building packages
sudo apt-get install libsdl1.2-dev
sudo apt-get install zlib1g-dev
sudo apt-get install checkinstall
sudo apt-get build-dep qemu

Extract qemu and kqemu

Make sure you substitute the x for your version number.
cd $HOME/src
tar zxvf qemu-0.7.x.tar.gz
cd qemu-0.7.x
tar zxvf ../kqemu-0.7.x.tar.gz
sudo ln -s /usr/src/linux-headers-$(uname -r) /usr/src/linux-headers
cd qemu-0.7.x


Edit the configure file

vi configure

change this line:

kernel_path=""

To this

kernel_path="/usr/src/linux-headers"

After you save and quit, run:
./configure

You should see something similar to the following:

harrisj@brightstar:~/src/qemu-0.7.2$ ./configure
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
Manual directory /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path /home/harrisj/src/qemu-0.7.2
C compiler gcc
Host C compiler gcc
make make
host CPU i386
host big endian no
target list i386-user arm-user armeb-user sparc-user ppc-user i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu
gprof enabled no
static build no
SDL support yes
SDL static link yes
mingw32 support no
Adlib support no
FMOD support no
kqemu support yes

KQEMU Linux module configuration:
kernel sources /usr/src/linux-headers
kbuild type 2.6
harrisj@brightstar:~/src/qemu-0.7.2$

If everything has gone as planned, you should have yes next to kqemu.

Now type

make

When you install a package from source there is usually no way to uninstall that package. This can cause problems down the track when you want to upgrade a program, there is no way to uninstall the old package safely.

This is where “checkinstall” steps in. Checkinstall creates a .deb package for you, which is easy to remove later.

Create the deb package.

sudo checkinstall -D

At this point checkinstall will ask you some questions.

1st question: Answer = default y
2nd question: Answer = Any description you like about qemu

You can safely leave the next menu alone and just press enter

Next, checkinstall will build the .deb package and install it. For me and other checkinstall reports that it fails and asks if you want to view the output.

Do not worry about this. Qemu did install successfully.

sudo vi /etc/modules

Add to the bottom:
kqemu
tun

Load them manually for now:
sudo modprobe kqemu
sudo modprobe tun

This section is the hardest section but it brings great rewards. If you want the virtual machine to be accessible by any other computer on the network this section is necessary.

Other wise you can use “user mode” networking.

Install bridge utilities and user mode utilities

sudo apt-get install bridge
sudo apt-get install uml-utilities

A network bridge is a virtual network interface that contains one or more real/virtual interfaces. Basically what this does is:

Create a bridge device
Add our eth0 (or other LAN device) to the bridge.
Modify security permissions to allow qemu to add a Virtual interface to the bridge.

This will allow your virtual ip address of your virtual pc to have a real ip address on your internal LAN. Get it?

*Note – During this section you will lose network connectivity.
**Note – Please substitute eth0 for the name of your LAN interface.

Create the bridge interface
sudo brctl addbr br0
Give the LAN interface a neutral IP
sudo ifconfig eth0 0.0.0.0
Add the LAN interface to the bridge
sudo brctl addif br0 eth0

Next we have to modify the file /etc/network/interfaces to allow your bridge to obtain an ip address automatically. For static IP, check further below.

sudo vi /etc/network/interfaces

For Dynamic IP

# The primary network interface
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 1
bridge_hello 1
bridge_stp off

Now its time to restart the Network and restore network connectivty.

sudo /etc/init.d/hotplug restart
sudo /etc/init.d/network restart

To check if everything went well type ifconfig and check to see if the device br0 listed has an IP address.

Eg

br0 Link encap:Ethernet HWaddr 00:0C:6E:74:41:62
inet addr:192.168.0.77 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:6eff:fe74:4162/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3826802 errors:0 dropped:0 overruns:0 frame:0
TX packets:3899124 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2844083685 (2.6 GiB) TX bytes:3126628692 (2.9 GiB)

Wow you just created a network bridge in linux Good Job!

Now you have created a bridge and added your LAN interface, you can create the virtual interface for Qemu to use.

Create the tun interface – Be sure to substitute “harrisj” for your username.

sudo tunctl -u 'harrisj' -t tun0
sudo chgrp admin /dev/net/tun
sudo chmod g+w /dev/net/tun

sudo vi /etc/qemu-ifup

Change the file to the following:
#!/bin/sh
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

sudo chmod ug0+x /etc/qemu-if

As a last bit the /dev/kqemu device may not survive a reboot, to fix this...
vi /etc/init.d/bootmisc.sh

At the bottom add:

mknod /dev/kqemu c 250 0
chmod 666 /dev/kqemu


## TODO ##
Add content about not running qemu in bridged mode, include basic natting instructions. (Test network setup)