Question

I recently had the problem, that I wanted to boot a Xen Hypervisor from Uefi using Gummiboot.

Mostly for reasons of elegance I didn't want to fall back to Bios or use another (more clunky) boot manager. I didn't find a step-by-step guide, so I had to piece everything together from documentation. For Google to find, I'll answer my own question here.

I had previously posted it to the Arch forums, and after a few revisions I think I can post it here.

Regards,

RTT

Was it helpful?

Solution

Prerequisites:

a) A running gummiboot-loaded arch linux system with

b) a Xen-capable (this is standard in arch) Kernel image in the efi system partition (mine is mounted at /boot ; most distros mount it at /boot/efi)

Compiling Binutils

You need a version of binutils with support for x86_64-pep emulation. To obtain this you need to build binutils from source.

Get some packages

# pacman -S abs base-devel

Get the abs tree

# abs

Copy the folder containing the PKGBUILD to a working directory. For example your home:

$ cp -r /var/abs/core/binutils/ ~/ 

Open ~/binutils/PKGBUILD and find:

${srcdir}/binutils-${pkgver}/configure --prefix=/usr \
  --with-lib-path=/usr/lib:/usr/local/lib \
  --with-bugurl=https://bugs.archlinux.org/ \
  --enable-ld=default --enable-gold \
  --enable-plugins --enable-threads \
  --with-pic --enable-shared \
  --disable-werror --disable-multilib

Add parameter --enable-targets=x86_64-pep so the line reads

${srcdir}/binutils-${pkgver}/configure --prefix=/usr \
  --with-lib-path=/usr/lib:/usr/local/lib \
  --with-bugurl=https://bugs.archlinux.org/ \
  --enable-ld=default --enable-gold \
  --enable-plugins --enable-threads \
  --with-pic --enable-shared \
  --disable-werror --disable-multilib \
  --enable-targets=x86_64-pep

Compile and install binutils by running

$ cd ~/binutils
$ makepkg
# pacman -U binutils*.pkg.tar.xz

(if makepkg wants packages, get them)

Compiling Xen

Now you need to build Xen from AUR.

Here's the package: https://aur.archlinux.org/packages/xen/

And here's the how-to: https://wiki.archlinux.org/index.php/AUR

(at this point you can switch back to the normal binutils package, in order to get upgrades in the future)

Efi configuration

If Xen compiled as it should, you will find a xen-*.efi in /usr/lib/efi/. Several actually, but only one is real, the rest are just links.

Copy it to the efi partition.

# cp -L /usr/lib/efi/xen.efi /boot/

Generate a xen.cfg file in /boot. Mine looks like this, but I'm new to Xen, so there are probably better settings you can choose. Check the Xen wiki for advice. Remember to replace the UUID with the one of your root partition file system. Likewise with the kernel image and the ramdisk, if you have a different setup.

[global]
default=xen

[xen]
options=console=vga dom0_mem=1024M,max=1024M dom0_max_vcpus=2 loglvl=all noreboot
kernel=vmlinuz-linux root=UUID=d07a95fe-f633-43a4-9996-8c8f76272344 rw ignore_loglevel #earlyprintk=xen
ramdisk=initramfs-linux.img

Gummiboot doesn't need a lot of information. Just make a new file in /boot/loader/entries/ (eg. xen.conf) containing the following:

title           Xen Hypervisor
efi             /xen.efi

You may need to adjust the timeout for the gummiboot menu and/or the default selection. Edit /boot/loader/loader.conf for this.

Done!

You can now configure your Dom0 and you can start adding DomUs by the normal guide in the Arch wiki.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top