Difference between pages "Package:Eselect (OpenGL)" and "UEFI Install Guide"

(Difference between pages)
 
 
Line 1: Line 1:
{{Ebuild
+
This tutorial will show you how to install Funtoo on a UEFI system. UEFI, also known as the [[Wikipedia:Unified Extensible Firmware Interface|Unified Extensible Firmware Interface]], is a new firmware interface that is used on some newer computers as a replacement for the traditional PC BIOS. It has an integrated boot loader, so setting up booting is different.
|Summary=A Gentoo/Funtoo utility that allows the active OpenGL implementation on a system to be switched between a variety of installed options.
+
|CatPkg=app-admin/eselect-opengl
+
|Maintainer=
+
}}
+
== Introduction ==
+
  
Eselect (OpenGL) (also called <tt>eselect-opengl</tt>) is a module for [[Package:Eselect|Eselect]] that allows the OpenGL implementation on a Funtoo Linux or Gentoo Linux system to be switched between a variety of installed OpenGL implementations. It functions by creating an <tt>env.d</tt> file at <tt>/etc/env.d/03opengl</tt> which contains OpenGL settings, as well as managing symbolic links to OpenGL libraries and headers.  
+
This tutorial is meant to be an "overlay" over the Regular Funtoo Installation. Follow the normal installation and only follow steps in this tutorial when dealing with partitioning and configuring the boot loader (GRUB). All steps are otherwise identical to the regular installation process.
  
=== Sample env.d File ===
+
== What Are We Doing? ==
  
A sample <tt>env.d</tt> file for a multilib system with xorg-x11 OpenGL implementation may look like this:
+
This guide will show you how to set up your UEFI system to load the GRUB boot loader, which will then load your Funtoo Linux kernel and initramfs. This is the "UEFI + GRUB" method as described on the [[Boot Methods]] page.
  
{{file|name=/etc/env.d/03opengl|desc=An example env.d file for eselect-opengl|body=
+
== First Steps ==
# Configuration file for eselect
+
# This file has been automatically generated.
+
LDPATH="/usr/lib32/opengl/xorg-x11/lib:/usr/lib64/opengl/xorg-x11/lib"
+
OPENGL_PROFILE="xorg-x11"
+
}}
+
  
== Implementation ==
+
To install Funtoo Linux on a UEFI system, first you need to boot SysRescueCD in UEFI mode. To do this, enable UEFI in your BIOS, and if necessary disable legacy booting. After some fiddling, you should be able to boot SysRescueCD and get a black and white text menu instead of the traditional aqua/cyan-colored menu. The black and white menu indicates that you booted SysRescueCD in UEFI mode. Once you've accomplished this, you're ready to continue with your Funtoo Linux installation and partition your drive. See below for details.
  
Eselect-opengl is implemented as a single bash-based [[Package:Eselect|Eselect]] module approximately 10K in size, installed at <tt>/usr/share/eselect/modules/opengl.eselect</tt>. One interfaces with this module via the main <tt>eselect</tt> command:
+
'''If the <tt>/sys/firmware/efi</tt> directory exists, then you have successfully booted in EFI mode and will be able to configure your Funtoo system to boot in EFI mode. If the directory doesn't exist, fix this first. It is a requirement for setting up EFI booting.'''
 +
 
 +
== Partitioning ==
 +
 
 +
To set up your partitions for UEFI booting, you will create a ~500MB FAT32 partition on <tt>/dev/sda1</tt>, and set it to type <tt>EF00</tt> using <tt>gdisk</tt>.
  
 
<console>
 
<console>
# ##i##eselect opengl help
+
Command: ##i##n ↵
Manage the OpenGL implementation used by your system
+
Partition Number: ##i##1 ↵
Usage: eselect opengl <action> <options>
+
First sector: ##i##↵
 +
Last sector: ##i##+500M ↵
 +
Hex Code: ##i##EF00
 +
</console>
  
##g##Standard actions:
+
This partition will serve as your Funtoo <tt>/boot</tt> filesystem as well as the partition that the UEFI firmware can read to load GRUB. Then you will set up swap on <tt>/dev/sda2</tt> and your root filesystem on <tt>/dev/sda3</tt>. To create the FAT32 filesystem, type:
  help                      Display help text
+
  usage                    Display usage information
+
  version                  Display version information
+
  
##g##Extra actions:
+
<console>
  list                      List the available OpenGL implementations.
+
# ##i##mkfs.vfat -F 32 /dev/sda1
  set <target>              Select the OpenGL implementation.
+
    <target>                  The profile to activate
+
    --use-old                If an implementation is already set, use that one instead
+
    --prefix=<val>            Set the source prefix (default: /usr)
+
    --dst-prefix=<val>        Set the destination prefix (default: /usr)
+
    --ignore-missing          Ignore missing files when setting a new implementation
+
  show                      Print the current OpenGL implementation.
+
 
</console>
 
</console>
  
== What is Switched ==
+
Your <tt>/etc/fstab</tt> entry for this filesystem will also differ, and will look like this:
  
Using <tt>eselect opengl set</tt> causes the following symbolic links to be updated to point to the files corresponding to the OpenGL implementation that you chose:
+
<pre>
 +
/dev/sda1 /boot vfat noatime 1 2
 +
</pre>
  
* ''Libraries'' (32-bit and 64-bit):
+
== Kernel ==
** <tt>/usr/lib(64)/libGL.so.*</tt>
+
** <tt>/usr/lib(64)/libEGL.so.*</tt>
+
** <tt>/usr/lib/(32|64|)/libGLESv1.so.*</tt>
+
** <tt>/usr/lib/(32|64|)/libGLESv2.so.*</tt>
+
* ''C Headers'':
+
** <tt>/usr/include/GL/*</tt>
+
** <tt>/usr/include/EGL/*</tt>
+
** <tt>/usr/include/KHR/*</tt>
+
* <tt>/usr/lib(64|)/xorg/modules/extensions/libglx.so</tt>
+
  
The symbolic links point to an installed OpenGL implementation, stored inside <tt>/usr/lib(32|64|)/opengl/(implementation-name)</tt>. These files are structured as follows:
+
=== VFAT ===
  
* <tt>/usr/lib/opengl/(implementation-name)/lib</tt>
+
Make sure you add VFAT support to your kernel if you are building it manually.
* <tt>/usr/lib/opengl/(implementation-name)/include/(GL|EGL|KHR)</tt>
+
* <tt>/usr/lib/opengl/(implementation-name)/extensions/libglx.so</tt>
+
  
On multilib systems, ebuilds that provide an OpenGL implementation install 32-bit libraries in <tt>/usr/lib32/opengl/(implementation name)/lib</tt> and 64-bit libraries in <tt>/usr/lib64/opengl/(implementation name)/lib</tt>.
+
=== EFI Framebuffer ===
  
== Criticisms ==
+
If you have the following option enabled in your kernel, then uvesafb and efifb will not be able to detect the framebuffer:
 +
 
 +
{{kernelop|title=Bus options (PCI etc.)|desc=
 +
    [*] Mark VGA/VBE/EFI FB as generic system framebuffer (NEW)
 +
}}
 +
 
 +
If you have that option enabled, ''you must also enable'':
 +
 
 +
{{kernelop|title=Device Drivers,Graphics support,Frame buffer Devices,Support for frame buffer devices|desc=
 +
    [*]  Simple framebuffer support
 +
}}
 +
 
 +
This is the preferred method of using the EFI framebuffer, the efifb and uvesafb drivers will be used as a fallback if the above is not compatible.
 +
 
 +
== Kernel ==
 +
 
 +
 
 +
== Boot Loader ==
 +
 
 +
=== Emerging GRUB ===
 +
 
 +
You will still use GRUB as a boot loader, but before emerging grub, you will need to enable EFI booting. To do this,
 +
add the following line to <tt>/etc/portage/make.conf</tt>:
 +
 
 +
<pre>
 +
GRUB_PLATFORMS="efi-64"
 +
</pre>
 +
 
 +
Then, <tt>emerge grub</tt>. You will notice <tt>efibootmgr</tt> getting pulled in as a dependency. This is expected and good.
 +
 
 +
=== Installing GRUB ===
 +
 
 +
Now, for the magic of getting everything in place for booting. You should copy your kernel and initramfs (if you have one -- you will if you are following the default install) to <tt>/boot</tt>. GRUB will boot those. But how do we get UEFI to boot GRUB? Well, we need to run the following command:
 +
 
 +
<console>
 +
# ##i##grub-install --target=x86_64-efi --efi-directory=/boot /dev/sda
 +
</console>
 +
This command will simply install all the stuff to <tt>/boot/EFI</tt> and <tt>/boot/grub</tt> that your system needs to boot. In particular, the <tt>/boot/EFI/grub/grubx64.efi</tt> file will be created. This is the GRUB boot image that UEFI will load and start.
 +
=== Configuring GRUB ===
  
=== Violation of Build Consistency ===
+
OK, now UEFI has the GRUB image it needs to boot. But we still need to configure GRUB itself so it finds and boots your kernel and initramfs. This is done by performing the following steps. Since boot-update doesn't yet support UEFI, we will not use boot-update directly and will create a <tt>/boot/grub/grub.cfg</tt> file manually that looks like this:
  
As documented in {{Bug|FL-1309}}, sometimes packages fail to merge when the "wrong" eselect opengl implementation is selected. This violates Portage's ability to consistently build a package from source, assuming all its dependencies are satisfied. This could be classified as a design bug -- eselect-opengl is functioning as intended, but its underlying theory of operation is not correct.
 
  
===== Possible Solutions =====
+
<pre>
 +
set timeout=3
 +
set gfxmode=auto
 +
insmod efi_gop
 +
insmod efi_uga
  
A possible solution to this problem, discussed in {{Bug|FL-1309}}, is to redesign eselect-opengl to only select the ''runtime'' OpenGL implementation, but to have all ebuilds build against the official xorg-x11 OpenGL implementation.
+
menuentry "Funtoo Linux genkernel - kernel-debian-sources-x86_64-3.2.35-2" { 
 +
    insmod part_gpt
 +
    insmod fat 
 +
    set root=(hostdisk//dev/sda,gpt1) 
 +
    search --no-floppy --fs-uuid --set __REPLACE_UUID_OF_SDA1__
 +
    linux /kernel-debian-sources-x86_64-3.2.35-2 real_root=/dev/sda3
 +
    initrd /initramfs-debian-sources-x86_64-3.2.35-2 
 +
    set gfxpayload=keep
 +
}
 +
set default=0
 +
</pre>
  
The rationale for this design change is that:
+
Note the <tt>search</tt> line where it says '''<tt>__REPLACE_UUID_OF_SDA1__</tt>''' above. You will need to run '''<tt>blkid /dev/sda1</tt>''' and use the UUID value that is displayed. For example, on my system, I need to use '''<tt>C34B-19CF</tt>'''. You can also change the <tt>menuentry</tt> line text in quotes to say whatever you want, and the <tt>linux</tt> and <tt>initrd</tt> lines should reference your kernel versions in <tt>/boot</tt>. As above, use the path <tt>/</tt> instead of <tt>/boot</tt> as the path should be relative to the root of the VFAT filesystem.
# There should be a consistent and repeatable build/linking process for all OpenGL applications.
+
# AMD and NVIDIA implementations of OpenGL are designed to be more of a "drop-in" runtime replacement for xorg-x11, rather than a standalone replacement for xorg-x11, and thus appear to exhibit more build-time bugs.
+
  
 +
== Known Issues ==
 +
With pure UEFI boot mode, with legacy mode disabled, following error expected:
 +
* video driver not supported, boot hangs, hard reboot required.
 +
Choose UEFI first, next legacy driver. It depends on motherboard vendor and efi bios version.
 +
In UEFI bios choose grub option, if your succeeded with above guide, additional menu should appear in Boot Menu, otherwise it boots into EFI shell:
 +
* grub:NAME of you hard drive
  
 +
=== Done! ===
  
 +
Remember to follow all other steps in the regular Funtoo Install Guide. Assuming you did everything correctly, your system should now boot via UEFI! We will be adding UEFI support to boot-update soon to make this process easier.
  
{{EbuildFooter}}
+
[[Category:HOWTO]]

Revision as of 19:57, 28 June 2014

This tutorial will show you how to install Funtoo on a UEFI system. UEFI, also known as the Unified Extensible Firmware Interface, is a new firmware interface that is used on some newer computers as a replacement for the traditional PC BIOS. It has an integrated boot loader, so setting up booting is different.

This tutorial is meant to be an "overlay" over the Regular Funtoo Installation. Follow the normal installation and only follow steps in this tutorial when dealing with partitioning and configuring the boot loader (GRUB). All steps are otherwise identical to the regular installation process.

What Are We Doing?

This guide will show you how to set up your UEFI system to load the GRUB boot loader, which will then load your Funtoo Linux kernel and initramfs. This is the "UEFI + GRUB" method as described on the Boot Methods page.

First Steps

To install Funtoo Linux on a UEFI system, first you need to boot SysRescueCD in UEFI mode. To do this, enable UEFI in your BIOS, and if necessary disable legacy booting. After some fiddling, you should be able to boot SysRescueCD and get a black and white text menu instead of the traditional aqua/cyan-colored menu. The black and white menu indicates that you booted SysRescueCD in UEFI mode. Once you've accomplished this, you're ready to continue with your Funtoo Linux installation and partition your drive. See below for details.

If the /sys/firmware/efi directory exists, then you have successfully booted in EFI mode and will be able to configure your Funtoo system to boot in EFI mode. If the directory doesn't exist, fix this first. It is a requirement for setting up EFI booting.

Partitioning

To set up your partitions for UEFI booting, you will create a ~500MB FAT32 partition on /dev/sda1, and set it to type EF00 using gdisk.

Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +500M ↵
Hex Code: EF00

This partition will serve as your Funtoo /boot filesystem as well as the partition that the UEFI firmware can read to load GRUB. Then you will set up swap on /dev/sda2 and your root filesystem on /dev/sda3. To create the FAT32 filesystem, type:

# mkfs.vfat -F 32 /dev/sda1

Your /etc/fstab entry for this filesystem will also differ, and will look like this:

/dev/sda1		/boot		vfat		noatime	1 2

Kernel

VFAT

Make sure you add VFAT support to your kernel if you are building it manually.

EFI Framebuffer

If you have the following option enabled in your kernel, then uvesafb and efifb will not be able to detect the framebuffer:

Under Bus options (PCI etc.):

[*] Mark VGA/VBE/EFI FB as generic system framebuffer (NEW)

If you have that option enabled, you must also enable:

Under Device Drivers-->Graphics support-->Frame buffer Devices-->Support for frame buffer devices:

[*]   Simple framebuffer support

This is the preferred method of using the EFI framebuffer, the efifb and uvesafb drivers will be used as a fallback if the above is not compatible.

Kernel

Boot Loader

Emerging GRUB

You will still use GRUB as a boot loader, but before emerging grub, you will need to enable EFI booting. To do this, add the following line to /etc/portage/make.conf:

GRUB_PLATFORMS="efi-64"

Then, emerge grub. You will notice efibootmgr getting pulled in as a dependency. This is expected and good.

Installing GRUB

Now, for the magic of getting everything in place for booting. You should copy your kernel and initramfs (if you have one -- you will if you are following the default install) to /boot. GRUB will boot those. But how do we get UEFI to boot GRUB? Well, we need to run the following command:

# grub-install --target=x86_64-efi --efi-directory=/boot /dev/sda

This command will simply install all the stuff to /boot/EFI and /boot/grub that your system needs to boot. In particular, the /boot/EFI/grub/grubx64.efi file will be created. This is the GRUB boot image that UEFI will load and start.

Configuring GRUB

OK, now UEFI has the GRUB image it needs to boot. But we still need to configure GRUB itself so it finds and boots your kernel and initramfs. This is done by performing the following steps. Since boot-update doesn't yet support UEFI, we will not use boot-update directly and will create a /boot/grub/grub.cfg file manually that looks like this:


set timeout=3
set gfxmode=auto
insmod efi_gop
insmod efi_uga

menuentry "Funtoo Linux genkernel - kernel-debian-sources-x86_64-3.2.35-2" {  
    insmod part_gpt
    insmod fat  
    set root=(hostdisk//dev/sda,gpt1)  
    search --no-floppy --fs-uuid --set __REPLACE_UUID_OF_SDA1__
    linux /kernel-debian-sources-x86_64-3.2.35-2 real_root=/dev/sda3
    initrd /initramfs-debian-sources-x86_64-3.2.35-2  
    set gfxpayload=keep
}
set default=0

Note the search line where it says __REPLACE_UUID_OF_SDA1__ above. You will need to run blkid /dev/sda1 and use the UUID value that is displayed. For example, on my system, I need to use C34B-19CF. You can also change the menuentry line text in quotes to say whatever you want, and the linux and initrd lines should reference your kernel versions in /boot. As above, use the path / instead of /boot as the path should be relative to the root of the VFAT filesystem.

Known Issues

With pure UEFI boot mode, with legacy mode disabled, following error expected:

  • video driver not supported, boot hangs, hard reboot required.

Choose UEFI first, next legacy driver. It depends on motherboard vendor and efi bios version. In UEFI bios choose grub option, if your succeeded with above guide, additional menu should appear in Boot Menu, otherwise it boots into EFI shell:

  • grub:NAME of you hard drive

Done!

Remember to follow all other steps in the regular Funtoo Install Guide. Assuming you did everything correctly, your system should now boot via UEFI! We will be adding UEFI support to boot-update soon to make this process easier.