Booting XEN on Ubuntu via Grub with UEFI
If you have Ubuntu 18.04 (or possibly even 16.x or earlier) and are trying to boot a XEN kernel using GRUB2[.efi] on a UEFI system, you will likely run into “blank screen/hanging” problems as others have found (e.g. here and here).
A fix for the issue is in Grub 2.04, but current stable releases of Debian and Ubuntu are still using Grub 2.02 - specifically, Debian (as of version 10, aka Buster) therefore downstream Ubuntu (18.4/Bionic, and 19.04/Disco, at the moment). I see that Grub 2.04 is in Debian Testing (11 / Bullseye), so hopefully it will make it into Ubuntu soon. Until then, there are some, IMO, overly complicated solutions are to get XEN to boot directly via EFI or building GRUB from source.
Simpler, and working for me on Ubuntu 18.04[.02] and Grub 2.02 (specifically 2.02-2ubuntu8.13), I was able to make use of a first-draft patch and modify it to directly patch /etc/grub.d/20_linux_xen
.
*** 20_linux_xen.orig 2019-03-18 11:11:57.000000000 -0500
--- 20_linux_xen 2019-07-15 19:41:30.810703315 -0500
***************
*** 91,96 ****
--- 91,100 ----
type="$4"
args="$5"
xen_args="$6"
+ ver=""
+ if $($grub_file --is-x86-multiboot2 ${xen_dirname}/${xen_basename}); then
+ ver="2"
+ fi
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
***************
*** 130,145 ****
else
xen_rm_opts="no-real-mode edd=off"
fi
! multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
! module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
message="$(gettext_printf "Loading initial ramdisk ...")"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
! module --nounzip ${rel_dirname}/${initrd}
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
--- 134,149 ----
else
xen_rm_opts="no-real-mode edd=off"
fi
! multiboot${ver} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
! module${ver} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
message="$(gettext_printf "Loading initial ramdisk ...")"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
! module${ver} --nounzip ${rel_dirname}/${initrd}
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
Apply this patch with:
cd /etc/grub.d
patch -c -i 20_linux_xen.patch
For the short term, or until Grub 2.04 (with this “official” patch) becomes mainline in Debian/Ubuntu, I think this is a much simpler solution than booting directly via EFI and does not require rebuilding Grub from source.