viernes, 29 de octubre de 2010

Instalar Xen4.0 en Ubuntu 10.04 LTS

Instalar los siguientes paquetes:

apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev


Si estamos en 64-bits
apt-get install gcc-multilib


Instalar las dependencias.
apt-get build-dep xen-3.3


Descargar las fuentes para el kernel

cd /usr/src
git clone
git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
cd linux-2.6-xen
git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x


Configurar el kernel, habilitar todo lo correspondiente a Xen.
make menuconfig




Compilar e Instalar
export CONCURRENCY_LEVEL=(number_of_cores) +1
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-xen kernel-image kernel-headers
dpkg -i ../linux-image-2.6.32.24-xen_2.6.32.24-xen-10.00.Custom_amd64.deb
update-initramfs -c -k 2.6.32.24-xen


Obtener codigo fuente de XEN

cd /usr/src/
wget http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
tar xf xen-4.0.1.tar.gz
cd xen-4.0.1


Aplicar los siguientes cambios en la carpeta xen-4.0.1


--- .orig/tools/hotplug/Linux/xen-backend.rules 2010-10-05 14:08:56.436012895 +0400
+++ /tools/hotplug/Linux/xen-backend.rules 2010-10-05 11:48:38.694087211 +0400
@@ -9,3 +9,5 @@
KERNEL=="evtchn", NAME="xen/%k"
KERNEL=="blktap[0-9]*", NAME="xen/%k"
KERNEL=="pci_iomul", NAME="xen/%k"
+KERNEL=="gntdev", NAME="xen/%k"
+KERNELS=="xen", KERNEL=="xvd*", SUBSYSTEM=="block", OPTIONS+="last_rule"


Compilar Xen

make xen
make tools
make install-xen
make install-tools PYTHON_PREFIX_ARG=


Actualizar scripts de inicio

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20


Esitar script de arranque. /etc/init.d/xend


-- xend.orig 2010-10-06 18:44:35.055245544 +0400
+++ xend 2010-10-06 18:46:26.056620024 +0400
@@ -21,7 +21,7 @@

shopt -s extglob
test -f /etc/sysconfig/xend && . /etc/sysconfig/xend
-
+/sbin/modprobe -v xenfs
if test "x$1" = xstart && \
test -d /proc/xen && \
! test -d /proc/xen/capabilities && \
@@ -57,6 +57,11 @@
test -z "$XENCONSOLED_TRACE" || export XENCONSOLED_TRACE
[[ "$XENSTORED_TRACE" == @(yes|on|1) ]] && export XENSTORED_TRACE
[[ "$XENBACKENDD_DEBUG" == @(yes|on|1) ]] && export XENBACKENDD_DEBUG
+ /sbin/modprobe -v xen-evtchn
+ /sbin/modprobe -v xen-gntdev
+ /sbin/modprobe -v xen-blkback
+ /sbin/modprobe -v xen-netback
+ /sbin/modprobe -v blktap
xend start
await_daemons_up
;;


Editar /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
loop
lp
rtc
xen-evtchn
xen-gntdev
xen-netback
xen-blkback
xenfs
blktap


Editar Grub2 según corresponda:

vim /etc/grub.d/45_custom

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.

menuentry 'Ubuntu, with Linux 2.6.32.24-xen' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod raid
insmod mdraid
insmod ext2
set root='(md1)'
search --no-floppy --fs-uuid --set 7b5672a0-774b-47fc-a8a3-7f93ded442b8
multiboot /boot/xen-4.0.1.gz dummy=dummy
module /boot/vmlinuz-2.6.32.24-xen dummy=dummy root=/dev/md1 ro console=tty0
module /boot/initrd.img-2.6.32.24-xen
}