Tuesday, September 13, 2011

Dual booting RHEL6 and Citrix Xenserver 6 beta

If you have limited hardware resources available and you want to test multiple virtualization solution then dual boot comes to the rescue. Citrix Xenserver claims the whole disk for itself, so we need at least two disks. If you have raid card in the server, just create 2 or more logical disks. Otherwise you need at least 2 physical disks.
Install Xenserver 6 beta on the first disk (sda in my case). After that install RHEL 6 (or centos6 or scientific linux 6 or ..) on the second disk (sdb in my case) and install grub on the first disk (sda). Don't modify the grub during RHEL install, we will do that later. After the install boot in RHEL6 (Well xenserver is out of the questions since our grub for now only can boot rhel6).
Mount the root disk of the xenserver in rhel6 /mnt and get the boot params:
[root@host1 ~]# mount /dev/sda1 /mnt
[root@host1 ~]# cat /mnt/boot/extlinux.conf
# location mbr
serial 0 115200
default xe
prompt 1
timeout 50

label xe
  # XenServer
  kernel mboot.c32
  append /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console= vga=mode-0x0311 --- /boot/vmlinuz-2.6-xen root=LABEL=root-bhsbdzef ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-2.6-xen.img

label xe-serial
  # XenServer (Serial)
  kernel mboot.c32
  append /boot/xen.gz com1=115200,8n1 console=com1,vga dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M --- /boot/vmlinuz-2.6-xen root=LABEL=root-bhsbdzef ro console=tty0 xencons=hvc console=hvc0 --- /boot/initrd-2.6-xen.img

label safe
  # XenServer in Safe Mode
  kernel mboot.c32
  append /boot/xen.gz nosmp noreboot noirqbalance acpi=off noapic dom0_mem=752M com1=115200,8n1 console=com1,vga --- /boot/vmlinuz-2.6-xen nousb root=LABEL=root-bhsbdzef ro console=tty0 xencons=hvc console=hvc0 --- /boot/initrd-2.6-xen.img

label fallback
  # XenServer (Xen 4.1.1 / Linux 2.6.32.12-0.7.1.xs5.9.960.497.170655xen)
  kernel mboot.c32
  append /boot/xen-4.1.1.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M --- /boot/vmlinuz-2.6.32.12-0.7.1.xs5.9.960.497.170655xen root=LABEL=root-bhsbdzef ro xencons=hvc console=hvc0 console=tty0 --- /boot/initrd-2.6.32.12-0.7.1.xs5.9.960.497.170655xen.img

label fallback-serial
  # XenServer (Serial, Xen 4.1.1 / Linux 2.6.32.12-0.7.1.xs5.9.960.497.170655xen)
  kernel mboot.c32
  append /boot/xen-4.1.1.gz com1=115200,8n1 console=com1,vga dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M --- /boot/vmlinuz-2.6.32.12-0.7.1.xs5.9.960.497.170655xen root=LABEL=root-bhsbdzef ro console=tty0 xencons=hvc console=hvc0 --- /boot/initrd-2.6.32.12-0.7.1.xs5.9.960.497.170655xen.img

We have serveral boot labels, but I'm only interested in the first one. If you want more, you can add as many as you like.
Now we update our grub.conf with the info from the append line. Just after the append we find the kernel info, just until the first ---. After that we have the first module info and after the second --- we have the second module info. So my /etc/grub.conf (which is a link to /boot/grub/grub.conf) looks like:
default=0
timeout=25

title Red Hat Enterprise Linux (2.6.32-131.0.15.el6.x86_64)
	root (hd1,0)
	kernel /vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root=/dev/mapper/vg_kvmtest1-root rd_LVM_LV=vg_kvmtest1/root rd_LVM_LV=vg_kvmtest1/swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
	initrd /initramfs-2.6.32-131.0.15.el6.x86_64.img

title Citrix Xenserver 6.beta
	root (hd0,0)
	kernel /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console= vga=mode-0x0311
	module /boot/vmlinuz-2.6-xen root=LABEL=root-bhsbdzef ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash
	module /boot/initrd-2.6-xen.img
If you use ssh to connect to your servers (who doesnt?) and you use the same ip for rhel6 as xenserver, it can be handy to set both host keys the same (otherwise you will be constantly editing your know_hosts file). With still /mnt mounted you can:
[root@host1 ~]# \cp /mnt/etc/ssh/ssh_host* /etc/ssh/
[root@host1 ~]# /etc/jnit.d/sshd restart