Xen installation on Debian GNU/Linux


Description :

How to install and configure Xen on Debian GNU/Linux and create one domU with network access in bridge mode.
Summary:
|-- Installation
|-- Configuration
	|-- Xen
	|-- xen-tools
|-- domU creation
|-- Useful commands
|-- Sources
|-- Changelog



.: Installation :.

Pre-requis

 - an up to date Debian GNU/Linux
 - archictecture amd64 (we will show i386 commands)
 - a functional network configuration
 - a beer pack 
Packages installation
amd64:
root@btg # aptitude install linux-image-2.6-xen-amd64 linux-headers-2.6-xen-amd64 bridge-utils
root@btg # aptitude install xen-hypervisor-amd64 xen-utils-3.2-1 xen-tools
i386:
root@btg # aptitude install linux-image-2.6-xen-686 linux-headers-2.6-xen-686 bridge-utils
root@btg # aptitude install xen-hypervisor-i386 xen-utils-3.2-1 xen-tools
Restart on the new kernel.


.: Configure Xen :.

Open the file /etc/xen/xend-config.sxp and verifiy theses lines are not comments:

# Create a bridge to have a network access
# If interface name is not the default one, you can give the name you want like that:
#	(network-script 'network-bridge netdev=$interface')
(network-script network-bridge)

# Bridge configuration script
(vif-script vif-bridge)

# Minimal reserved memory for dom0 (in Mb)
(dom0-min-mem 196)

# Enable memory management
# If you have more details about this option (and the ballooning), we would be happy if you can help us
(enable-dom0-ballooning yes)

# Number of CPU (0 = all)
(dom0-cpus 0)


.: Configure de xen-tools :.

Open the file /etc/xen-tools/xen-tools.conf and verifiy theses lines are not comments:

# Created images directory
dir = /home/bobotrax/xen

# Installation method:
#   - debootstrap :	installation via debootstrap
#   - rpmstrap :	installation via rpmstrap
#   - rinse : 		installation via rinse
#   - copy : 		installation by copying a previous installation
#   - tar : 		installation by decompressing an archive
install-method = debootstrap

# domU caracteristics
size   = 4Gb      # disk space
memory = 128Mb    # memory
swap   = 128Mb    # swap
# noswap = 1      # do not use swap
fs     = ext3     # filesystem (ext2, etx3, xfs, reiserfs)
dist   = lenny    # default distribution
image  = sparse   # use dynamic image (like Virtualbox does)

# Network configuration
# For a manual configuration:
# 	gateway   = 192.168.2.1
# 	netmask   = 255.255.255.0
# 	broadcast = 192.168.2.255
dhcp = 1

# If you want to import users from dom0
# accounts = 1

# Ask for the root password creation during the installation
passwd = 1

# Defaults kernel and ramdisk
kernel      = /boot/vmlinuz-`uname -r`
initrd      = /boot/initrd.img-`uname -r`

# Architecture (i386, amd64)
arch=amd64

# Download mirror
mirror = http://ftp.ca.debian.org/debian/

# Mount options
ext3_options   = noatime,nodiratime,errors=remount-ro
ext2_options   = noatime,nodiratime,errors=remount-ro
xfs_options    = defaults
reiser_options = defaults


.: domU creation :.

To create a domU named domubtg, just try this:

root@btg # xen-create-image --hostname domubtg --role udev
While creation, root password will be asked.

Note: --role udev will install udev after the domU creation.
In case you forgot it, you could not access to the domU using ssh.
It will be enough to chroot the created image and install udev:
root@btg # xen shutdown domubtg
root@btg # mount -o loop /home/bobotig/xen/domains/domubtg/disk.img /mnt/disk
root@btg # chroot /mnt/disk
root@btg # aptitude install udev
root@btg # exit
root@btg # umount /mnt/disk
root@btg # xen create /etc/xen/domubtg.cfg
When you try to chroot, if an error like that occures:
chroot: ne peut exécuter la commande `/bin/zsh': Aucun fichier ou répertoire de ce type

Please think to change your current shell for your profile:
root@btg # chsh
And enter:
/bin/bash
Logout and login to take effect.
You can now try another time to chroot and then see you that you can access to your virtual machine.


.: Useful commands :.

Few useful commands to manage domU:

# Create
xen-create-image --hostname $domU_name --role udev

# Delete
xen-delete-image $domU_name
# Start
xm create /etc/xen/$domU_name.cfg

# Stop
xm shutdown $domU_name

# Restart
xm reboot $domU_name

# Kill
xm destroy $domU_name
# Pause
xm pause $domU_name

# Resume
xm unpause $domU_name
# List all states
xm list


.: Sources :.


.: Changelog :.