You are not logged in.

#1 2013-12-13 20:57:03

Rikki-Tikki-Tavi
Member
Registered: 2013-12-12
Posts: 8

How To: Xen on UEFI systems using Gummiboot

Hi there,

This is my first How To and only my second post in this forum, I will need your help to iron out any problems with this and assumptions I have unwittingly made. Maybe we can migrate this to the Wiki at some point.

My standpoint: I just got a new laptop and want to trick it out with a sophisticated installation, for no other reason than that it's a piece of home I carry with me and I want to feel comfortable with it. I wanted to reduce legacy software as much as possible. I couldn't get wayland running well, yet, but UEFI is a must. I did not want to force my poor new core i7 to pretend it's a fossil from the 80s for the first second or so of boot time. Also, I may look at secure boot in the future.

I found a bunch of information on Xen with (u)efi scattered around here and there on the internet, but no step-by-step how-to. So having spend a day and a half reading up on all kinds of stuff related to this, I wanted to share my result with the community.

So without further ado:

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)

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

# pacman -S abs base-devel

1.b) get the abs tree

# abs

1.c) copy the folder containing the PKGBUILD to a working directory. For example your home:

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

1.d) 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

1.e) compile and install binutils by running

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

(if makepkg wants packages, get them)

2. 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>

3. Now for the 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. Figure out which one is real.
3.a) copy it to the efi partition (you may have to replace the version number)

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

3.b) 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 (suggestions welcome). Remember to replace the UUID with the one of your root partition file system. Likewise with the kernel image, the ramdisk, maximum cores and memory, if you have a different setup.

[global]
default=xen

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

3.c) 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<your_version_number>.efi

And of course, put in your xen version number. You may also need to adjust the timeout for the gummiboot menu and/or the default selection. Edit /boot/loader/loader.conf for this.

Done!

Now you have a working Dom0 and can start adding DomUs by the normal guide:
https://wiki.archlinux.org/index.php/xen

Last edited by Rikki-Tikki-Tavi (2014-01-06 14:03:59)

Offline

#2 2014-02-10 13:37:26

zir_blazer
Member
Registered: 2013-12-12
Posts: 35

Re: How To: Xen on UEFI systems using Gummiboot

Did anyone else tried using Arch Linux with Xen in UEFI mode with success following this guide? I have tried some months ago and was unable to, it either black screens or freezes while booting depending on some parameters.

http://lists.xen.org/archives/html/xen- … 01044.html

I think I heared elsewhere that the reason why it doesn't work is because for UEFI to work with Xen, you need a special kernel, but according to what you said, it is standard on Arch Linux so I suppose it should be already ready to use.

I'm not in mood to keep pushing for UEFI at the moment, but I want to have fresh ideas to know what else I can try the next time I have the will to try to make it work. Possibly when Xen 4.4 gets released I'm going to give this a try again.

Offline

#3 2014-03-08 12:06:05

Rikki-Tikki-Tavi
Member
Registered: 2013-12-12
Posts: 8

Re: How To: Xen on UEFI systems using Gummiboot

I had KMS enabled. Maybe you should give that a try.

Offline

#4 2014-03-08 12:21:35

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: How To: Xen on UEFI systems using Gummiboot

The wiki is a better place for information like this.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2014-04-19 08:39:38

rayanamukami
Member
Registered: 2014-04-19
Posts: 8

Re: How To: Xen on UEFI systems using Gummiboot

Thank you very much for compiling this guide. Regarding "3.a) Copy xen-*.efi in /usr/lib/efi/ to
the efi partition", I can't find the file "xen-*.efi" nor directory "/usr/lib/efi/". The only .efi
files i could find elsewhere are:
/usr/lib/gummiboot/gummibootx64.efi/gummibootx64.efi
~/AUR/xen/src/xen-4.4.0/tools/firmware/etherboot/ipxe/src/arch/x86/Makefile.efi
~/AUR/xen/src/xen-4.4.0/tools/firmware/etherboot/ipxe/src/arch/x86_64/Makefile.efi
~/AUR/xen/src/xen-4.4.0/tools/firmware/etherboot/ipxe/src/arch/i386/Makefile.efi
Does this mean that xen did not compile as it should?

Offline

#6 2014-06-02 21:40:58

Rikki-Tikki-Tavi
Member
Registered: 2013-12-12
Posts: 8

Re: How To: Xen on UEFI systems using Gummiboot

@graysky: If you read the initial post, I wanted to encourage some discussion before taking that step. But you're welcome to move it yourself.

@rayanamukami: Yes, it seems it didn't compile right. Can you post the relevant section of your "binutils/PKGBUILD" (i.e. the one around the line that we canged)?

Offline

#7 2014-07-04 16:18:48

tritron4
Member
Registered: 2012-04-14
Posts: 153

Re: How To: Xen on UEFI systems using Gummiboot

I get this echo 'EFI installation only partially done (EFI_VENDOR not set

Offline

#8 2014-07-05 01:11:38

Rikki-Tikki-Tavi
Member
Registered: 2013-12-12
Posts: 8

Re: How To: Xen on UEFI systems using Gummiboot

Seems to be an issue with newer versions of of the Xen package. I don't have the setup anymore, so I can't test this, but try setting the efi vendor as an environment variable in the fakeroot environment before building Xen. Like so:

# export EFI_VENDOR=arch

I think "arch" is the correct vendor name, but check your efi system partition if you want to be sure:
https://wiki.archlinux.org/index.php/Arch_boot_process

Last edited by Rikki-Tikki-Tavi (2014-07-05 01:12:08)

Offline

#9 2014-08-11 01:30:19

zir_blazer
Member
Registered: 2013-12-12
Posts: 35

Re: How To: Xen on UEFI systems using Gummiboot

Up to this day, I'm still very puzzled about your success with Xen and UEFI. One of my goals was to get it working, but never managed to do so. While the last time that I tried experimenting with this and doing everything from scratch was months ago, I have been looking on the progress on this area and supposedly, Dom0 couldn't work with Xen in UEFI because Xen couldn't pass Dom0 the EFI variables, or something along these lines. Support for this is supposed to be added in the next Linux kernel version, 3.17...
http://www.phoronix.com/scan.php?page=n … px=MTc1NDg

Also, there were two ways to do this: One, booting with the xen.efi directly like you do in your guide, and another one (Which more people seemed to be interested in for some reason) was to use GRUB to launch the EFI executable. The second one failed too because GRUB after doing its thing didn't passed Xen the EFI services. On xen-devel Mailing List I saw every now and then some patches related to EFI support and GRUB. However, I fail to realize what benefit there is by using GRUB during the UEFI booting process if you can boot the EFI executable directly. Point is, both methods were incomplete, so I don't know how you did it.

Last edited by zir_blazer (2014-08-11 08:11:51)

Offline

#10 2014-09-15 04:52:26

zir_blazer
Member
Registered: 2013-12-12
Posts: 35

Re: How To: Xen on UEFI systems using Gummiboot

Yesterday I had the will to experiment one more time with this. It still fails in the exact same way with latests Arch Linux and Xen 4.4.1. However, I decided to give the AUR linux-git kernel a try, which is the 3.17 RC4 version that should have already included the UEFI Dom0 support that I mentioned in my previous Post. I downloaded it, builded it with the default config options, and after one hour and half of compiling, I got a package. Installed it, changed the xen.cfg lines to use it instead of the default one, and rebooted. And guess what, finally the damn thing booted.

I still don't know why it worked for some other people previously while it is the first time I got it working. What the people that managed to boot with xen.efi and a Dom0 Arch Linux UEFI install had different to me?



Also, after booting in UEFI mode, I didn't checked if xenstored and xenconsoled are running. On a regular Xen install, when you install the xen package, you can use systemctl enable <service> to get them running, enabling them is as easy as that because they're already there. As I didn't installed the xen package, I don't know if the procedure to enable these services is different. Will try later. I suppose that I would have to manually use these lines from xen PKGBUILD:

    install -Dm644 conf.d-xenstored "$pkgdir"/etc/conf.d/xenstored
    install -Dm644 conf.d-xenconsoled "$pkgdir"/etc/conf.d/xenconsoled

Last edited by zir_blazer (2014-09-15 05:51:43)

Offline

#11 2014-10-27 03:59:37

kantras
Member
Registered: 2013-06-04
Posts: 12

Re: How To: Xen on UEFI systems using Gummiboot

If you had build 4.4.1 from source, not via the AUR package, then you'd have to use init.d scripts in order to start services; they are only including systemd service files with the upcoming 4.5.0 release, so we include some service files within the AUR package for now.

Offline

Board footer

Powered by FluxBB