Getting Xen up and running


Now that Xen and a dom0-capable kernel have been installed, it’s time to combine the two.

There’s essentially two steps to this:

  1. Set up grub to boot Xen
  2. Set up Fedora to automatically start the Xen management services

Setting up grub to boot Xen

Officially, the easiest way to modify the grub configuration file is to use grubby, a tool designed specifically to do so. Unfortunately, it doesn’t support the syntax Xen requires (yet, there’s a bug report filed against it about this problem).

So, that means we have to manually modify the grub configuration file, located at /boot/grub/menu.lst

You can do this either at the desktop (using GUI text editing programs such as gedit) or the command line (using vim or other text editors).

Grub boot menu in Vim

Grub boot menu in Vim

The syntax Xen requires is unique – Xen works by starting the Xen hypervisor, then it starts your OS to administer and interact with the Xen hypervisor. Hence, it needs to know both the location of your kernel and the initial RAM disk image (aka the file named initramfs) when booting your computer.

While grubby isn’t the most ideal option (in it’s current form), I’ve had good experiences using it to avoid having to copy options from the automatically installed kernels over to the entry for the xen-enabled kernel. (Do a yum install grubby if you run grubby but get a command not found.)

Since I compiled my own kernel and copied it over to /boot, I just needed to specify the kernel location.

grubby --title="Xen on Fedora Test" --add-kernel=/boot/vmlinuz-2.6.32.39 --copy-default --add-multiboot=/boot/xen.gz --mbargs="dom0_mem=1024M loglvl=all"

Of particular note is the mbargs=”dom0_mem=1024M loglvl=all” portion. This specifies the options passed to the Xen hypervisor. In this case, I’ve set it so that Domain0 will be limited to 1GB of RAM, and that the hypervisor will log every event. The –copy-default option saves copying the kernel options.

Finally, you’ll have to add the initramfs line. Open the grub boot menu, and go to the end of the first entry (which should be your newly created Xen entry) and start a new line. Type module /,  followed by the filename of your created RAMdisk, which should be something like initramfs-2.6.32.39.img

Once you’ve done that, the complete entry should look something like:

title Xen on Fedora Test
        root (hd0,0)
        kernel /xen.gz dom0_mem=1024M loglvl=all
        module /vmlinuz-2.6.32.39 ro root=/dev/mapper/vg_caesium-lv_root rd_DM_UUID=pdc_dbijaaabh rd_LVM_LV=vg_caesium/lv_root rd_LVM_LV=vg_caesium/lv_swap rd_NO_LUKS rd_NO_MD LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet
        module /initramfs-2.6.32.39.img

Don’t worry if it’s not exactly the same, the kernel options and filenames will no doubt vary.

Set up Fedora to automatically start the Xen management services

chkconfig --list|grep xen to check that the management services are installed & setup to run. You should get something like

[[email protected] ~]# chkconfig --list|grep xen
xen-watchdog    0:off   1:off   2:off   3:on    4:on    5:on    6:off
xencommons      0:off   1:off   2:off   3:on    4:on    5:on    6:off
xend            0:off   1:off   2:off   3:on    4:on    5:on    6:off
xendomains      0:off   1:off   2:off   3:on    4:on    5:on    6:off

If you don’t get any output, or xend, xendomains or xencommons aren’t present, run

chkconfig --add xend
chkconfig --add xendomains
chkconfig --add xencommons

If you don’t see on anywhere in the list, that means the management services are installed, but not setup to run automatically. Run

chkconfig --levels=345 xend on
chkconfig --levels=345 xendomains on
chkconfig --levels=345 xencommons on

to get them to start automatically.

  1. No comments yet.
(will not be published)