Configuring GRUB2 for Xen on Gentoo
GRUB2 is highly customizable and feature-rich, however it is a bit of a nightmare if you configure bootloaders regularly. Unfortunately GRUB 0.97 doesn’t support ext4 and – if you were an idiot like me – you might have set up your new dedicated with an ext4 /boot. Now, you have neither the time nor patience to re-install and need to make Xen go.
First, copy your Dom0 .config and kernel to /boot/. /etc/grub.d/20_linux_xen picks up on the CONFIG_XEN_PRIVILEGED_GUEST=y variable.
# cp /usr/src/linux/arch/x86_64/boot/bzImage /boot/kernel-dom0 # cp /usr/src/linux/.config /boot/config-dom0
Next, remove the executable flag from /etc/grub.d/10_linux or you will end up with three or four entries that boot straight to the Dom0 kernel without the hypervisor.
# chmod -x /etc/grub.d/10_linux
To add kernel boot parameters to your grub.cfg (as generated with grub2-mkconfig and 20_linux_xen) add these lines to your /etc/default/grub file:
The former will place your boot options on the Dom0 kernel’s module line. The latter will place boot options on the xen.gz hypervisor’s kernel line.
Now, generate your new configuration:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Once the config file has been written, determine the position of the Xen hypervisor entry and update GRUB_DEFAULT in /etc/default/grub.
Install GRUB2 to your MBR(s) as necessary:
# grub2-install /dev/sda