Install Xen 4.8/4.9 on Ubuntu 16.04 with UEFI Booting

People (like me) may meet many troubles when installing Xen on a machine which only supports UEFI booting. It’s not impossible, but a hassle, to make it work.

In my case, my machine doesn’t play legacy boot mode well, and I have to build Xen from source because my final goal is to introduce some new features to it.

  1. First, download Xen (4.8.2 in my case) source codes from the official site.
  2. Install dependencies (may not be complete)
    $ sudo apt-get install build-essential bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial libjpeg-dev make gcc libc6-dev-i386 zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libpixman-1-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev bison flex xz-utils libyajl-dev gettext markdown libaio-dev pandoc liblzma-dev libnl-3-dev libnl-utils libnl-cli-3-dev
  3. Unzip the package, and build the source
    $ cd xen-4.8.2
    $ ./configure –libdir=/usr/lib 
    $ make world -j8 
    $ sudo make install 
    $ sudo update-rc.d xencommons defaults 
    $ sudo update-rc.d xendomains defaults 
    $ sudo ldconfig 
  4. Add EFI entry. and match the place where your EFI loader is.
    # mkdir /boot/efi/EFI/xen 
    # cp /usr/lib64/efi/xen-4.8.2.efi /boot/efi/EFI/xen/xen.efi 
    # cp /boot/vmlinuz-<kernel_version> /boot/efi/EFI/xen 
    # cp /boot/initrd.img-<kernel_version> /boot/efi/EFI/xen/ 
    # efibootmgr -c -d <disk> -p <partition> -w -L Xen -l "\EFI\xen\xen.efi" 
  5. Add EFI config file. Parameters can be gotten by cat /proc/cmdline.
    # vim /boot/efi/EFI/xen/xen.cfg
    options=console=vga,com1 com1=115200,8n1 iommu=verbose ucode=scan flask=disabled conring_size=2097152  loglvl=all 
    kernel=vmlinuz-<kernel_version> BOOT_IMAGE=/vmlinuz-<kernel_version> root=UUID=<root_uuid> ro quiet sysrq_always_enable dvt.handoff=7 console=hvc0 
  6. Reboot!

Then you should enter Xen domain 0. Verify with sudo xl list.

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.