Grub 2
grub2 has added support for Xen 32- and 64-bit paravirtualization.
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 VPS 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.
grub>
- 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 tested:
- ufs2
- ext3
- ext4
With these file systems available without having 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
fi
done
done
done
if [ -f "(xen/xvda,msdos1)/boot/grub/menu.lst" ] ; then
set root=(xen/xvda,msdos1)
legacy_configfile /boot/grub/menu.lst
fi
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:
- legacy_parse.patch - ignores root in legacy config files, probably not required
- xen-hd.patch - handles disks named
hd<X>
, pulled from this upstream commit - xen-fix-dl-ref.patch - makes module reference code more like grub-core/loader/i386/linux.c, possibly not required
- xen-linux16.patch - maps linux16/initrd16 commands to linux/initrd, pulled from this patch
- xen-initrd-ctx-init.patch - keeps failures of initrd from crashing grub2, modeled off of this upstream
To generate the executables:
$ 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