From PrgmrWiki


grub2 has added support for xen paravirtualization. 32-bit support only works on more recent versions of xen (currently only on field and lefanu) while 64-bit support works everywhere.


Pre-Generated Distributions

The distributions available on /distros may have a config file available for grub2, but they have not been edited to be sane (for example, the search path for root includes a UUID.) You will need to regenerate the file using the tools for your distribution.

Changing bootloader

32-bit grub2 is available on the platforms that support it. On the ones that don't, switching from pv-grub to grub2 will force 64-bit mode and switching from 64-bit to 32-bit mode will force pv-grub.
Log into the management console. Select option 9 to switch between pv-grub and grub2.

If 32-bit grub2 is not available and "i386" is the current bootloader, you will see:

    9. swap pvgrub/grub2 bootloaders currently "pv-grub"
       This will also switch from i386 to amd64.

    0. exit

If 32-bit grub2 is available and "i386" is the current bootloader, you will see:

    9. swap pvgrub/grub2 bootloaders currently "grub2"

    0. exit

Rescue Image

grub2 boots directly to your hard drive because the rescue image will not attempt to load any grub2 configuration files. To use the rescue image, either switch back to pv-grub or do the following at the grub2 prompt:

  • type 'c' to enter a command line. You will see a screen like:
                  GNU GRUB  version 2.02~beta2-9ubuntu1+prgmr1

   Minimal BASH-like line editing is supported. For the first word, TAB   
   lists possible command completions. Anywhere else TAB lists possible   
   device or file completions. ESC at any time exits.                     

  • Set root to be xvde
grub> set root='xen/xvde,msdos1'
  • Load legacy configuration file for rescue image
grub> legacy_configfile /boot/grub/menu.lst

Compatible file systems

The following file systems have been explicitly tested:

  • ufs2
  • ext3
  • ext4

The following are available but have not been tested:

  • affs
  • afs
  • bfs
  • btrfs
  • cbfs
  • hfs
  • hfsplus
  • jfs
  • nilfs2
  • ntfs
  • reiserfs
  • sfs
  • ufs1
  • ufs1_be
  • xfs
  • zfs
  • zfscrypt

Config file search paths

The following configuration file is compiled into the grub2 image:

insmod part_msdos
insmod part_bsd
insmod part_gpt

for part in msdos1 gpt1 bsd1; do
	for maindir in boot/ /; do
		for subdir in grub grub2; do
			if [ -f "(xen/xvda,$part)/$maindir/$subdir/grub.cfg" ]; then
				set root=(xen/xvda,$part)
				configfile /$maindir/$subdir/grub.cfg

if [ -f "(xen/xvda,msdos1)/boot/grub/menu.lst" ] ; then
  set root=(xen/xvda,msdos1)
  legacy_configfile /boot/grub/menu.lst

set root=(xen/xvde,msdos1)
legacy_configfile /boot/grub/menu.lst

The nested for loop will search first in (xen/xvda,msdos1)/boot/grub/grub.conf, then (xen/xvda,msdos1)/boot/grub2/grub.conf, and so forth.

Development background

The base source code is pulled from ubuntu trusty. The following patches were applied:

To generate the executables, I ran

grub-mkstandalone --compress=gz -O i386-xen -o grub2-x86_32.gz boot/grub/grub.cfg
grub-mkstandalone --compress=gz -O x86_64-xen -o grub2-x86_64.gz boot/grub/grub.cfg