Basic Setup of Xen3.2 32bit

From Wiki

Jump to: navigation, search


Background to 32bit Xen

This is on a server with 8GB of RAM. It had a bigmem kernel installed to begin with. The default 32bit Xen kernel that comes with Debian has PAE enabled, allowing all of the 8GB of RAM to be seen by Xen. Below is the output of free and uname -a.

============ Before ===============
Debian-50-lenny-32-minimal:~# free
             total       used       free     shared    buffers     cached
Mem:       8301232     179796    8121436          0      41128     103980
Debian-50-lenny-32-minimal:~# uname -a
Linux Debian-50-lenny-32-minimal 2.6.26-2-686-bigmem #1 SMP Thu Sep 16 20:29:07 UTC 2010 i686 GNU/Linux

Installation and Reboot

apt-get install xen-hypervisor-3.2-1-i386 linux-image-2.6-xen-686
# vi /boot/grub/menu.lst. Check default and entries.
# reboot

That's actually all there is involved. Debian's dependancies will select and install all additional packages required.

============ After ===============
Debian-50-lenny-32-minimal:~# free
             total       used       free     shared    buffers     cached
Mem:       8171204     212232    7958972          0       2492      20096
Debian-50-lenny-32-minimal:~# uname -a
Linux Debian-50-lenny-32-minimal 2.6.26-2-xen-686 #1 SMP Fri Sep 17 00:54:08 UTC 2010 i686 GNU/Linux
Debian-50-lenny-32-minimal:~# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  7979     8     r-----      8.5

All 8GB memory is available for use. (By default xen3.2 uses PAE).

Tweaks to dom0

These tweaks will help make dom0 more stable. It fixes the amount of memory available instead of having to balloon out. The networking is set to network-bridge as this is the most basic and easiest setup.

vi /boot/grub/menu.lst
# xenhopt=
# xenhopt=dom0_mem=256000

# ^ This will recreate the menu.lst. Check and go "vi menu.lst", it should now read: kernel  /xen-3.2-1-i386.gz dom0_mem=256000)

vi /etc/xen/xend-config.sxp
//change (dom0-min-mem 196) to:
(dom0-min-mem 256)
//change (network-script network-dummy) to:
(network-script network-bridge)

Create DomU

In this example a file based disk image will be used. It's possible to use LVM. For a LVM DomU creation see LVM_on_XEN_(dom0)

mkdir -p /xens/vm01
dd if=/dev/zero of=/xens/vm01/disk-vm01.img bs=1024k count=5000
dd if=/dev/zero of=/xens/vm01/swap-vm01.img bs=1024k count=512
mkfs.ext3 /xens/vm01/disk-vm01.img  (press y to continue if asked)
mkswap /xens/vm01/swap-vm01.img
mount -o loop /xens/vm01/disk-vm01.img /mnt/
apt-get install debootstrap
debootstrap lenny /mnt
cp /etc/apt/sources.list /mnt/etc/apt/
cp /etc/resolv.conf /mnt/etc/
cp /etc/network/interfaces /mnt/etc/network/
vi /mnt/etc/network/interfaces (update as necessary)
vi /mnt/etc/hostname
vi /mnt/etc/fstab
proc            /proc   proc    defaults                        0 0
/dev/sda1       /       ext3    defaults,errors=remount-ro      0 1
/dev/sda2       none    swap    sw                              0 0

chroot /mnt/
apt-get install udev
exit (from udev)

vi /etc/xens/vm01
kernel = "/boot/vmlinuz-2.6.26-2-xen-686"
ramdisk = "/boot/initrd.img-2.6.26-2-xen-686"
memory = 512
name = "vm01"
vif = ['bridge=xenbr0']
disk = ['file:/xens/vm01/disk-vm01.img,sda1,w','file:/xens/vm01/swap-vm01.img,sda2,w']
ip = ""
gateway = ""
netmask = ""
root = "/dev/sda1 ro"
extra = 'xencons=tty clocksource=jiffies'

ln -s /etc/xen/vm01 /etc/xen/auto/vm01
//link in the config file so that the Virtal Machine starts on Bootup of Dom0

Start DomU

cd /etc/xen
xm create -c vm01
//Login with root. There will be no password set.
passwd to change the password.
apt-get install linux-modules-2.6-xen-686
iptables -L (to test)
//To exit the Xen Console: CTRL + ]


So this will setup a basic Xen system with bridged networking and a file based disk image. All of the above was done on a basic installation of Debian Lenny. If you are new to Xen, I highly recommend you read over: Details,_Installation,_&_Set-up_of_Debian_based_Linux_Servers#Archive

Personal tools