XEN on LCFG
The following resources will turn a normal LCFG Linux box into an LCFG Linux XEN host.
At first place, the right packages should be installed and therefore the XEN package list must specified in the machines profile:
#include <lcfg/options/xen.h>
One package that is not included in this list, is the RPM of the
lcfg-xen
component. This is available from at
http://lcfg.ucs.ed.ac.uk/pkgs/devolved/world/sl5/rpms/lcfg-xen-0.99.3-1.noarch.rpm
It will need to be added in the profile as well:
!profile.packages mADD(lcfg-xen-0.99.3-1/noarch)
Next step is to populate existing resources with the
lcfg-xen
component. The following lines add the component in the component list of the machine, enable logserver to provide web based information, and is configured to start and stop automatically at boot and shutdown respectively:
!profile.components mADD(xen)
profile.version_xen 1
!logserver.components mADD(xen)
!boot.services mADD(lcfg_xen)
!boot.stop_lcfg_xen 5 restart
Because the previously defined
lcfg/options/xen.h
will install the XEN kernel, we'll need to create the appropriate symlinks for the kernel, initrd and the gz image. Otherwise, having a new XEN kernel installed after an update, the system will not be able to find the old kernel and will be unable to boot. The following resource will do the trick:
!kernel.kerneltype mSET(xen)
Having that done, what's left is configuring Grub in order to boot the XEN kernel:
!grub.menuitems_defaultboot mADD(xen)
grub.root_defaultboot_xen (hd0,4)
grub.kernel_defaultboot_xen /boot/xen.gz
grub.modules_defaultboot_xen kernel initrd
grub.module_defaultboot_xen_kernel /boot/vmlinuz root=/dev/sda5 ro quiet selinux=0
grub.module_defaultboot_xen_initrd /boot/initrd.img
grub.boot_defaultboot_xen yes
grub.title_defaultboot_xen Scientific Linux (XEN)
!grub.defaultboot_defaultboot mSET(4)
Depending on which drive/partition your LCFG installation lives, you may need to change the
grub.root_defaultboot_xen (hd0,4)
and
grub.module_defaultboot_xen_kernel /boot/vmlinuz root=/dev/sda5 ro quiet selinux=0
resources.
The last line,
!grub.defaultboot_defaultboot mSET(4)
, sets the XEN entry to be the default for booting. The number 4 in the parenthesis states that the fifth Grub entry should become the default for booting. In order to get the right numbering, you have to count your entries from top to bottom starting from 0.
Resources example:
!xen.virtualmachines mADD(sl5vm)
!xen.name_sl5vm mSET(sl5vm)
!xen.uuid_sl5vm mSET(6f2cffa1-21f6-43b4-8c52-08b8277a38a3)
!xen.maxmem_sl5vm mSET(1024)
!xen.memory_sl5vm mSET(1024)
!xen.vcpus_sl5vm mSET(2)
!xen.disks_sl5vm mADD(osdisk, swap)
!xen.diskname_sl5vm_osdisk mSET(sl5vmos)
!xen.disktype_sl5vm_osdisk mSET(image)
!xen.disksize_sl5vm_osdisk mSET(24)
!xen.diskname_sl5vm_swap mSET(sl5vmswap)
!xen.disktype_sl5vm_swap mSET(image)
!xen.disksize_sl5vm_swap mSET(1)
!xen.diskpath_sl5vm_swap mSET(/var/lib/xen/images/swap)
!xen.vifs mADD(vif1 vif2)
!xen.mac_vif1 mSET(00:1e:c9:52:30:ce)
!xen.mac_vif2 mSET(00:1e:c9:51:32:ac)
!xen.bridge_vif2 mSET(xenbr1)
!xen.script_vif2 mSET(network-bridge-private)
!xen.boot_sl5vm mSET(yes)
Based on these resources the component will create a new guest called sl5vm and its configuration file will be /etc/xen/sl5vm. A specific UUID is given, 1G of memory will be allocated and two CPUs will be used. The component will create two disk images. 24G for the system disk and 1G for a disk image to be used as swap memory. The swap disk image will be stores in a different location than the default, /var/lib/xen/images/swap. The guest will also have two network interfaces (eth0 and eth1). The second one will be assigned a private LAN address.
Doing a 'man lcfg-xen' will give you a description of all the available resource followed by syntax.
NOTE: The current version of the component (0.99.3-1) assumes that the top level directory where the disk image will be stored already exists. That is not the case every time. Apply the following patch to
/usr/lib/lcfg/components/xen for getting the directories created in case they don't exist. The patch will also make the component to check if the directory and the disk image have been created successfully. These operations will be added on the next release of the component.
Patch:
http://www2.epcc.ed.ac.uk/~pkritika/lcfg/lcfg-xen-0.99.3-1.1a.patch
To apply the patch run: # patch /usr/lib/lcfg/components/xen lcfg-xen-0.99.3-1.1a.patch
XEN guest
If you got your LCFG machine running as XEN host, then you can also get XEN guests running within the host. There is no automatic way of creating the guest, the building process is the same as for a normal LCFG machine (you'll need of course go through steps that of creating the initial XEN virtual machine configuration). The profile of the guest should have the following hardware resources:
!inv.model mSET(XEN Virtual Machine)
/* Adding IDE support */
!fstab.disks mSET(hda)
!fstab.partitions_hda mSET()
!fstab.dopartition_hda mSET(no)
!fstab.spec_root mSUBST(sda,hda)
!fstab.spec_swap mSUBST(sda,hda)
!fstab.spec_pie mSUBST(sda,hda)
!grub.installdev mSUBST(sda,hda)
!grub.kroot_defaultboot_disk1 mSUBST(sda,hda)
!grub.kroot_defaultboot_disk1single mSUBST(sda,hda)
!grub.timeout_defaultboot mSET(0)
/* end of IDE support */
/* Add modules */
!hardware.modlist mADD(eth scsi)
hardware.mod_eth alias eth0 tg3
hardware.mod_scsi alias scsi_hostadapter ata_piix
The IDE support configuration may need to be changed according to your local setup.
-- Main.pkritika - 04 Sep 2008