Xen setup

From skinetwork

Jump to: navigation, search

Important notes on xen configuration. This document is quick and dirty, so please read some xen documents before these steps.

Ok, here are brief steps of xen setup so that I dont forget

Get the xen kernel rpm and install, typically

> yum groupinstall "Virtualization"

Make sure the entry is made in the grub.conf to boot the xen kernel.

IMPORTANT: Check is the console=ttyS0 is specified in the boot options of the xen kernel, else that will block the xen guest and xen console cannot be connected

Get fedora 6 image from jailtime.org

Here is a the configuration file, note the spaces and [ ] etc...

kernel = "/boot/vmlinuz-2.6.18-1.2798.fc6xen"
ramdisk = "/boot/initrd-2.6.18-1.2798.fc6xen.img.2"
memory = 256
name = "fedora.fc6"
vif = ['mac=00:16:3e:62:d2:98, bridge=xenbr0']
# vif = [ '' ]
dhcp = "dhcp"
disk = ['file:/data/xen/guests/fedora/fedora.fc6.img,sdb1,w', 'file:/data/xen/guests/fedora/fedora.swap,sdb2,w']
root = "/dev/sdb1 ro"
extras = "3"

To create initrd-2.6.18-1.2798.fc6xen.img.2, use this command else boot will fail since xenblk and xennet modules are not included in our original initrd made when installing rpm of xen. So do the following to create one and use that initrd.

mkinitrd -f --preload=xenblk --with=xennet /boot/initrd-2.6.18-1.2798.fc6xen.img.2 2.6.18-1.2798.fc6xen

In the guest, if you are using ttyS0 device as the console, add it /etc/inittab in dom0 similar to other tty devices, tty0 tty1 etc, put a line for ttyS0, since that will be the terminal device we will be using.

Also if we want to login as root using this ttyS0 device we need put that in /etc/sysconfig/securetty file of dom0

Typically, if you want to connect using xm console command, then in the guest point output device to console and NOT tty1, see example below. Else everything boots fine but login prompt in xen guest does not appear.

Then, the command to start the guest is as follows:

xm create xenconfig/fedora.fc6.xen3.cfg -c console=ttyS0

about the console settings above, I guess I wrote it bit confusing, so here are the examples,

In DOM0, /etc/inittab settings looks like

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Modified for xen
c:2345:respawn:/sbin/mingetty ttyS0

In DOMU, xen guest, /etc/inittab looks like this

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty --noclear console
# 1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

NOTE ABOVE TTY1 IS COMMENTED AND INSTEAD ABOVE LINE IS USED.

Personal tools