Important: You are required to change your passwords used for Gentoo services and set an email address for your Wiki account if you haven't done so. See the full announcement and Wiki email policy change for more information.

UEFI Gentoo Quick Install Guide

From Gentoo Wiki
Jump to: navigation, search

It took me almost 2 days to figure out how to install and boot Gentoo on my new UEFI laptop.

I basically followed: http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml

The following are points where I diverged from that guide in order to have a working, bootable system.

First, there is no master boot record on a UEFI system.

Instead your BIOS loads a .efi file from a FAT32 partition that you tell it about (by issuing a command to it's firmware, we'll get to that later)

Make sure efivars kernel module is loaded:

root # modprobe efivars

Here is how I created my partitions. NOTE the way I wrote the mkpart commands ensures proper alignment on SSD drives. Change them at your own risk. (Can use align-check to see if you did it right):

root # parted /dev/sda
(parted) mkpart ESI fat32 0% 500m
(parted)
mkpart primary ext4 500m 100%
(parted)
set 1 boot on
(parted)
quit
root # mkfs.vfat -F 32 /dev/sda1
root #
mkfs.ext4 /dev/sda2
Note
Note that the boot flag parted sets is NOT the same thing as the bootable flag in the old master boot record.It's confusing that parted choose to use the same name, but they are different. Setting the boot flag by parted in a MBR partition marks that partition bootable, while in a GPT partition it is marked as EFI System Partition. Also note that ESI is not a typo..

Now continue along with the quickinstall guide.

For the kernel configuration, make sure you specify the kernel options mentioned here: EFI stub kernel

Here are my steps:

root # cd /usr/src/linux
root #
make menuconfig
root #
make modules_install
root #
mkdir /boot
root #
mount /dev/sda1 /boot
root #
mkdir -p /boot/efi/boot
root #
cp arch/x86/boot/bzImage /boot/efi/boot/bootx64.efi
root #
emerge efibootmgr

Now the tricky part. In order to tell the BIOS about your new bootx64.efi, you need to have booted the system WITH UEFI.

Since you likely used a CDROM to boot the system, it is unlikely that you booted with UEFI. Sad face :(

What does work, is if you stick your new bootx64.efi file on a USB flash stick, the laptop will automatically find that and boot it.

So insert a USB stick, we'll pretend it comes up as /dev/sdd in the following code:

root # parted /dev/sdd
(parted) mklabel gpt
(parted)
mkpart esi fat32 0% 500m
(parted)
set 1 boot on
(parted)
quit
root # mkfs.vfat -F 32 /dev/sdd1
root #
mkdir /mnt/tmp && mount /dev/sdd1 /mnt/tmp
root #
mkdir -p /mnt/tmp/efi/boot
root #
cp arch/x86/boot/bzImage /mnt/tmp/efi/boot/bootx64.efi
root #
umount /mnt/tmp

Now reboot the box and hit F2 (or whatever) to enter the BIOS on boot.

In the UEFI list, choose to boot the new USB flash stick that should be showing up.

The kernel should load up and boot your sytem.

Now you can tell the BIOS about your bootx64.efi that is on the hard drive:

root # efibootmgr -c -d /dev/sda -p 1 -L Gentoo -l "\efi\boot\bootx64.efi"
root #
reboot

Now enter the BIOS again and you should see "Gentoo" in the list!

Congrats, it should now boot!