Saturday, March 10, 2012

Multiboot ESXi 5, Windows 2008 R2, RHEL 6, XenServer 6

Congratulations, you decided to be the ultimate hypervisor egalitarian and install every mainstream hypervisor + KVM onto a single server.  You setup Windows 2000 and Redhat to dual boot 11 years ago, how much can things have changed?

I could have accomplished this project via constantly swapping harddrives when I needed to change hypervisors, but that seemed more like accepting the problem than a solution.

My initial plan was to divide my six harddrives into 4 logical volumes at the raid controller level.  Unfortunately the raid controller for servers I was using (I'm going to refrain from plugging any one vendor, at least as long as I'm operating on other people's hardware) doesn't provide this functionality.  For a brief moment I flirted with the idea of cutting up the disk using partitions, until a closer look at ESXi and Xen's installation revealed they don't provide any granularity in setup of the partition tables beyond selecting an installation volume.

Instead of telling this story as it happened, I'm going to first go over the hiccups I encountered on the way.  That way, incase you're like me and already started this project before doing your research, you can plan a bit before reading the whole article.

VMware Boot Bank Corruption
Not sure how I accomplished this on the first server, because I couldn't replicate it on the second.  I assumed it was because Microsoft was automounting the VMware Boot Banks (they are formatted fat32).  Anywho, for quite a long time I was stuck with the error "Not a VMware Boot Bank".  VMware provides very little information on this error (and not applicable to my situation).  Unfortunately VMware also doesn't seem to provide a way to fix a corrupted Boot Bank, so I was forced to reinstall.  Afterwards I ran this command to prevent Windows from auto-mounting these volumes:

diskpart
automount disable
exit

Windows installing onto the wrong drives
While Microsoft is nice enough to ask you which drive you'd like to install Windows on, that doesn't mean it'll listen.  Unfortunately while it will install your C: drive to the selected partition, it will install the 100MB System Reserved partition which it boots from to where it sees fit.   On a system with lots of unformatted drives like mine, and where I was installing Windows to not the first volume, it chose to put the system reserved partition and the MBR for windows on the first volume set, ensuring that it would be booted automatically.  I ended up fixing this by only leaving in the disks for Windows during it's installation process, then inserting the other disks after it was done.

XenServer is scared of VMFS volumes
Citrix, it's ok to be scared, but you need to face your fears.  Every time I booted the Xen installer it would die when it got the point of scanning the drives with the error "Could not parse Sgdisk".  From what I found via a quick google, this is due to an inability of the Xen 6 installer to handle VMFS volumes.  Citrix, this is no way to convert followers away from VMware.  I resolved this by making sure the disk I was installing Xen to was formatted and pulling the other disks out of the server during the installation of XenServer.

XenServer is scared of GPT volumes
Not sure if this was just from me, or why this was occuring, but I had to follow these instructions to get past a GPT error which occurred during the installation of Xen 6:

1. Boot from the XenServer 6.0.0 install CDROM.
2. At the Xen 6.0.0 install prompt type menu.c32 and press enter.
3. When you get the new menu screen press TAB
4. add disable-gpt just before the last --- then press enter.

BCDedit won't modify the configuration if it's not the primary disk
I promoted this to its own blog post.


The actual project
For these four hypervisors, there are three different boot loaders used, and two major versions of one of those boot loaders:

Windows 2008 R2Bootmgr
RedHat Enterprise LinuxGrub
VMware ESXi 5Syslinux 3.86
Citrix XenServer 6Syslinux 4.04


My original goal was to use Grub with RHEL 6 to load everything else.  This turned out to be a much simpler task than the hours of time I burned on it made it appear.  I thought the errors I was receiving in ESXi due to a corrupted boot bank were from some problem with Grub chainloading Syslinux, turns out i had really just corrupted my boot bank.

Boot everything from Grub
This turned out to be rather simple due to support for something called "chainloading".  My final working grub configuration is:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_ccskvmvmh01-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=2
#timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
 root (hd0,0)
 kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_ccskvmvmh01-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto rd_NO_DM rd_LVM_LV=vg_ccskvmvmh01/lv_root rd_LVM_LV=vg_ccskvmvmh01/lv_swap
 initrd /initramfs-2.6.32-220.el6.x86_64.img
title Windows 2008 R2
 rootnoverify (hd1)
 chainloader +1

title ESXi 5
 rootnoverify (hd2)
 chainloader +1

title XenServer 6
 rootnoverify (hd3)
 chainloader +1

Grub simply hands off booting to the MBR on the respective drives, and the boot loaders for the other hypervisors takes it from there.

Of course since this didn't initially work for me, I went through all the additional effort to also make this for from ESXi's and Xen's Syslinux to boot everything, and I made an effort (but did not finish) making Bootmgr boot everything else.

Boot everything from ESXi 5 (Syslinux 3.86)
This works pretty much the same way, with two major caveats.  First, VMware was not nice enough to ship menu.c32 or chain.c32 with the installation of ESXi 5.  Therefore you need to go here, download Syslinux 3.86 and extract those two files.

Second, ESXi doesn't mount it's first partition, so you can't do any of this from within ESXi's console.  I'd recommend a linux boot disk, or if you chose to dual boot with RHEL 6, you can mount it from there.  You'll know you have the right partition if you see the files:

syslinux.cfg
safeboot.c32
mboot.c32

Copy chain.c32 and menu.c32 into this partition.  Now backup syslinux.cfg and replace it with the following:

ui menu.c32

label esxi
menu label ESXi 5
COM32 safeboot.c32

label win
menu label Windows 2008 R2
COM32 chain.c32
APPEND hd1

label xen
menu label XenServer 6
COM32 chain.c32
APPEND hd3

label linux
menu label RedHat Enterprise 6
COM32 chain.c32
APPEND hd0
 
Pretty simple.

Boot everything from Xen 6 (Syslinux 4.04)
Citrix was nice enough to include both menu.c32 and chain.c32 in their boot partition.  I didn't check to see if they mounted this within their OS or not, and simply edited it out of band anyways.  Since I was already done with most everything at this point, I didn't change it to use the menu config but instead left it with requiring you to enter the label at the boot prompt.

The file you want to edit this time is extlinux.conf.  Again, I suggest making a backup first:

# 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-ckxrtmdk 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-ckxrtmdk 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-ckxrtmdk 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.xs6.0.0.529.170661xen)
  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.xs6.0.0.529.170661xen root=LABEL=root-ckxrtmdk ro xencons=hvc console=hvc0 console=tty0 --- /boot/initrd-2.6.32.12-0.7.1.xs6.0.0.529.170661xen.img

label fallback-serial
  # XenServer (Serial, Xen 4.1.1 / Linux 2.6.32.12-0.7.1.xs6.0.0.529.170661xen)
  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.xs6.0.0.529.170661xen root=LABEL=root-ckxrtmdk ro console=tty0 xencons=hvc console=hvc0 --- /boot/initrd-2.6.32.12-0.7.1.xs6.0.0.529.170661xen.img

label redhat
com32 chain.c32
append hd0

label win
com32 chain.c32
append hd1

label esxi
com32 chain.c32
append hd2

Boot everything from Bootmgr
First note, I never actually go this working.  Booting Grub from Bootmgr is easy.  I'm sure it's possible somehow to boot Syslinux from Bootmgr, but after accomplishing the above tasks this seemed like a trivial exercise.  Still, I figured I'd list what I did.

First I pulled the mbr off each of the disks:

dd if=/dev/sda of=/tmp/linux.bin bs=512 count=1
dd if=/dev/sdc of=/tmp/syslinux.bin bs=512 count=1
dd if=/dev/sdd of=/tmp/xen.bin bs=512 count=1

Then I copied the files I created to the root of the C: drive for Windows.  Then within BCD edit I ran:

bcdedit /create /d “Linux” /application BOOTSECTOR
bcdedit /set {ID} device partition=c:
bcdedit /set {ID}  path \linux.bin
bcdedit /displayorder {ID} /addlast

bcdedit /create /d “ESXi 5” /application BOOTSECTOR
bcdedit /set {ID} device partition=c:
bcdedit /set {ID}  path \syslinux.bin
bcdedit /displayorder {ID} /addlast

bcdedit /create /d “Xen 6” /application BOOTSECTOR
bcdedit /set {ID} device partition=c:
bcdedit /set {ID}  path \xen.bin
bcdedit /displayorder {ID} /addlast

bcdedit /timeout 30
{ID} should be replaced in each entry here by the ID which BCDedit gives you for that entry after you run the /create command.   When I was finished the configuration looked like this:

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=E:
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {default}
resumeobject            {69db61ae-5dc5-11e1-8bc1-bb2a8301fdf5}
displayorder            {default}
                        {53d01ece-5e3e-11e1-94cf-9e5144662cd0}
                        {657ad556-5e3e-11e1-94cf-9e5144662cd0}
                        {c4a9ea4a-6a30-11e1-8e1a-f59982b714d6}
toolsdisplayorder       {memdiag}
timeout                 10

Windows Boot Loader
-------------------
identifier              {default}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Windows Server 2008 R2
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {69db61b0-5dc5-11e1-8bc1-bb2a8301fdf5}
recoveryenabled         Yes
osdevice                partition=C:
systemroot              \Windows
resumeobject            {69db61ae-5dc5-11e1-8bc1-bb2a8301fdf5}
nx                      OptOut

Real-mode Boot Sector
---------------------
identifier              {53d01ece-5e3e-11e1-94cf-9e5144662cd0}
device                  partition=C:
path                    \syslinux.bin
description             ESXi

Real-mode Boot Sector
---------------------
identifier              {657ad556-5e3e-11e1-94cf-9e5144662cd0}
device                  partition=C:
path                    \linux.bin
description             RedHat

Real-mode Boot Sector
---------------------
identifier              {c4a9ea4a-6a30-11e1-8e1a-f59982b714d6}
device                  partition=C:
path                    \xen.bin
description             Xen

This seemed to boot Grub just fine, but everything else gave an error about no operating system found. I have not spent more time to troubleshoot it.

End Result
Everything available from Grub.   I know it's cheesy to take a picture of a monitor, but until someone gets me some test boxes with out of band management (hint hint, Cisco and/or Fujitsu), this is how it's going to be.


Credit: Information for this solution was gathered from numerous websites in addition to independent research.  In addition to the websites listed above, some of the others which provided instrumental information are:

http://www.legacycode.net/2010/01/31/esxi-3-5-server-2003-dualboot/
http://www.msfn.org/board/topic/135148-booting-bootmgr-from-syslinuxubcd/

10 comments:

  1. If you want to make it work with BCDEdit, do this:

    Install ESXi partition using this option during install time "formatwithmbr"...

    Found this out from wp.secretnets.info/?p=697

    Didn't work until used that option.

    Followed your directions for that section and once it was formatted that way... system booted into ESXi on the first try.

    ReplyDelete
    Replies
    1. The URL is bad. It should be wp.secretnest.info/?p=697 (the s and t were swapped around)

      Delete
  2. You should be able to reinstall ESXi over the top of itself and I selected reinstall not upgrade (second line that preserves the VMFS volumes).

    ReplyDelete
    Replies
    1. how did you install esxi the first time? pls see my question below.

      Delete
  3. Hi; how did you go about installing each hypervisor? what order did you install them in and what, if any, "tricks" did you employ in the process? thanks

    ReplyDelete
    Replies
    1. Hi Basat.

      Read my post below for a run through but in short if you install Windows first then install any other OS / Hypervisor you want after you can then use the Windows boot menu by using the EasyBCD tool/program.

      Cheers, Luke

      Delete
  4. A very interesting read. I have to say though I may have found an easier way to do this. Currently I have only got Windows Server 2012 and ESXi 5.1 dual booting (as that is all I need / want).

    I installed Windows Server 2012 (so I can use Hyper-V) first onto the first disk (HD0); as Chris explains above Windows does not like being placed anywhere but the first HDD.

    I then installed ESXi 5.1 onto the second disk (HD1). For this you need to select the second HDD as part of the ESXi installation.

    Once this was done I booted back into Windows Server 2012 (which is done automatically being as it is on the first disk). Once there i installed and the ran EasyBCD. In “Add New Entry”, I installed the NeoGrub bootloader and then clicked configure and appended the below to the end of the file and saved (dont forget to substitute hd1 with the drive you installed ESXi on if different to the second disk).

    default 0
    timeout 0

    title ESXi 5.1
    map (hd1) (hd0)
    chainloader (hd1)+1
    rootnoverify (hd1)

    Reboot and you will get a Windows boot menu with "Windows Server 2012" and "NeoGrub Bootloader" listed. Selecting "NeoGrub Bootloader" will boot to ESXi. Feel free to change timeouts and the "NeoGrub Bootloader" name back in Windows by running EasyBCD.

    I am sure if you install the other OS' in this blog (RHEL 6 & XenServer 6) onto other hard drives (say HD2 & HD3) then you can just add those entries into the "NeoGrub Bootloader" config file too.

    ReplyDelete
  5. I like what you have done there. I'd do it myself too soon. But, just to keep things simple, isn't installing Xen, and ESXi on flash drives save all the trouble?

    ReplyDelete
  6. Luke Lloyd, I can confirm that what you suggested works perfectly also with XenServer 6.2. Very easy - if you purchase the easybcd software :). But hey, 30$ is not much and are worth every penny. THX!!

    ReplyDelete
  7. Great blog!!!! Its really helps you to solve your problem go through it and free from your problem
    BOOTMGR Missing in Windows 7
    Thanks
    Aalia lyon

    ReplyDelete