Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Migrating existing Gentoo install to UEFI boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Mon Feb 01, 2016 5:55 pm    Post subject: [SOLVED] Migrating existing Gentoo install to UEFI boot Reply with quote

Currently using legacy boot/GRUB2. Disk is MBR. I want to do a pure UEFI boot so I've been reading WIKIs and old forum threads and I think I have a plan.

Wanted to run this by you and get feedback on if I've got this right or if I'm going to end up with a brick.

I don't use a initramfs so that should make life easier. It is also a single boot system, no windows or any other OS to worry about.

Current partitioning is

sda1: 100 MB boot
sda2: root
sda3: home

So the steps I've identified are:

1) Rebuild kernel with:

Code:
Firmware Drivers  --->
    <*> EFI Variable Support via sysfs

Processor type and features  --->
    [*] EFI runtime service support
    [*]   EFI stub support

Processor type and features  --->
    [*] Built-in kernel command line
    (root=/dev/sda2)

2) Backup my existing /boot directory.

3) Delete/change partition type to EF, format as FAT32 with "mkfs.vfat -F 32 /dev/sda1"

4) mount sda1 as /boot.

5) mkdir /boot/efi/boot

6) copy my new kernal to /boot/efi/boot/bootx64.efi

7) Reboot the machine and hopefully have a working system!!!

8) Use efibootmgr to create additional boot options as needed (older kernels).


Will this work?


Edit: It indeed works. Only thing to add is to also compile the kernel with 'CONFIG_FB_EFI=y' to get hi-res frame buffer/console and to remove any other frame buffer drivers (especially CONFIG_FB_UVESA).


Last edited by zwede on Tue Feb 02, 2016 12:41 am; edited 1 time in total
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 6:27 pm    Post subject: Reply with quote

Do not forget make.conf with

Code:
GRUB_PLATFORMS="efi-64"


and install grub
Code:
grub2-install --target=x86_64-efi --efi-directory=/boot


and I think it should be enough if I assume that your partition scheme will use GPT

EDIT : ho and I cannot remember where is the option but you will need this
Code:
CONFIG_EFI_PARTITION=y

_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5


Last edited by gulivert on Mon Feb 01, 2016 6:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
Syl20
Guru
Guru


Joined: 04 Aug 2005
Posts: 564
Location: France

PostPosted: Mon Feb 01, 2016 6:28 pm    Post subject: Reply with quote

I think no. You need a dedicated EFI partition besides your /boot one.
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 6:36 pm    Post subject: Reply with quote

CneGroumF wrote:
I think no. You need a dedicated EFI partition besides your /boot one.


Not needed for my case I just have my vfat partition directly mount to /boot

My fstab
Quote:
/dev/sda2 /boot vfat....

_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Mon Feb 01, 2016 6:47 pm    Post subject: Reply with quote

gulivert wrote:
Do not forget make.conf with

Code:
GRUB_PLATFORMS="efi-64"


and install grub
Code:
grub2-install --target=x86_64-efi --efi-directory=/boot


I want to get rid of grub, and have UEFI boot gentoo directly. I think that is possible?

Quote:

and I think it should be enough if I assume that your partition scheme will use GPT


I want to stay MBR. From what I've read that is ok as long as the drive is < 2 TB (it is way smaller).

Quote:
EDIT : ho and I cannot remember where is the option but you will need this
Code:
CONFIG_EFI_PARTITION=y


Not needed as long as I stay MBR, right?
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 7:12 pm    Post subject: Reply with quote

ok understood, good question, I do not have any knowledge about that but I'm interesting about the result :P

For myself I have grub2 to start my UEFI installation but if there is a way to get ride grub, let me know!
I tried to start the kernel directly without grub by directly booting on boot/efi/boot/bootx64.efi but I get a kernel panic that I do not have with grub

Maybe because I do not set anything for this
Code:
Processor type and features  --->
    [*] Built-in kernel command line
    (root=/dev/sda2)


EDIT : and right if you can use MBR you will not need this
Code:
CONFIG_EFI_PARTITION=y

This is for GPT support in the kernel
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 7:19 pm    Post subject: Reply with quote

ok found this from gentoo wiki
https://wiki.gentoo.org/wiki/EFI_stub_kernel

Intersting! I will try it.
As I read you will need a guid EF for the boot partition to works fine.
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 7:39 pm    Post subject: Reply with quote

Ok it works!
Just added this :
Code:
Processor type and features  --->
    [*] Built-in kernel command line
    (root=PARTUUID=D43FF789-F974-4472-82A8-3AE027B3DB8D)


Now if I boot without grub my Gentoo boot with OpenRC, but I prefere to use systemd, just need to find the way to switch that!

Thank you I learn something because of you :)
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Mon Feb 01, 2016 7:59 pm    Post subject: Reply with quote

gulivert wrote:
Now if I boot without grub my Gentoo boot with OpenRC, but I prefere to use systemd, just need to find the way to switch that!


Should be enough to add systemd to the kernel args

Code:
Processor type and features  --->
    [*] Built-in kernel command line
    (root=PARTUUID=D43FF789-F974-4472-82A8-3AE027B3DB8D) init=/usr/lib/systemd/systemd
Back to top
View user's profile Send private message
1clue
Advocate
Advocate


Joined: 05 Feb 2006
Posts: 2549

PostPosted: Mon Feb 01, 2016 8:14 pm    Post subject: Reply with quote

CneGroumF wrote:
I think no. You need a dedicated EFI partition besides your /boot one.


This is not correct. My EFI partition is 512M type EF00, formatted as FAT32 and mounted as /boot. It contains grub and its associated stuff as well as my EFI stuff.

EFI does not care where you mount it when you're up and running, it only cares that files it expects are where they should be with reference to the EF00 partition, and that the EF00 partition be formatted FAT32.

The OP said he wanted to do without grub, I don't know how to do that but my grub is at /boot/EFI/BOOT/bootx64.efi.

I don't intend to take this off into another direction, but wanted to clear up an error for others who read this thread.
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7550
Location: Goose Creek SC

PostPosted: Mon Feb 01, 2016 8:25 pm    Post subject: Reply with quote

Make sure you have a backup of root partition and home partition.
The disk needs to be GPT to work with UEFI. gdisk may do the job for you in a sequence like:
Quote:
fx8150 ~ # gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu

Command (? for help): t
Partition number (1-3): 1
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to 'EFI System'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sde.
The operation has completed successfully.


Kernel needs:
-*- Enable the block layer --->
Partition Types --->
[*] EFI GUID Partition support

recommend:
mkdir -p /boot/EFI/Boot vice mkdir /boot/efi/boot
copy new kernel to /boot/EFI/Boot/bootx64.efi
_________________
Defund the FCC.
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 8:28 pm    Post subject: Reply with quote

zwede wrote:
gulivert wrote:
Now if I boot without grub my Gentoo boot with OpenRC, but I prefere to use systemd, just need to find the way to switch that!


Should be enough to add systemd to the kernel args

Code:
Processor type and features  --->
    [*] Built-in kernel command line
    (root=PARTUUID=D43FF789-F974-4472-82A8-3AE027B3DB8D) init=/usr/lib/systemd/systemd


Right you are, it works! Then now how to remove grub2 .... haha I can start the kernel stub boot directly by keep pressing my ALT key at the computer boot and choose my kernel and it works. But if I do not do any thing, grub start...
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
glecomte
n00b
n00b


Joined: 20 Sep 2002
Posts: 19

PostPosted: Mon Feb 01, 2016 8:43 pm    Post subject: Reply with quote

you need efibootmgr in order to edit the EFI boot entries
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7550
Location: Goose Creek SC

PostPosted: Mon Feb 01, 2016 8:46 pm    Post subject: Reply with quote

An efi_stub kernel requires UEFI boot mode. UEFI needs the disk to be GPT. You probably have a bios/uefi that will boot uefi and legacy bios that you are booting in legacy bios mode. Some uefi bios have a mode choice such as UEFI, UEFI and Legacy BIOS, Legacy BIOS; some will display both UEFI and legacy BIOS options in the boot device list without a mode choice.
_________________
Defund the FCC.
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 8:49 pm    Post subject: Reply with quote

glecomte wrote:
you need efibootmgr in order to edit the EFI boot entries


Yop works! grub2 uninstalled and now the gentoo is booting properly.
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Mon Feb 01, 2016 9:02 pm    Post subject: Reply with quote

DONAHUE wrote:
The disk needs to be GPT to work with UEFI.


Are you sure about this? From what I've read UEFI is compatible with MBR, you just set the boot partition type as EF instead of EF00.
Back to top
View user's profile Send private message
gulivert
l33t
l33t


Joined: 17 Jun 2004
Posts: 863
Location: Switzerland

PostPosted: Mon Feb 01, 2016 9:16 pm    Post subject: Reply with quote

zwede wrote:
DONAHUE wrote:
The disk needs to be GPT to work with UEFI.


Are you sure about this? From what I've read UEFI is compatible with MBR, you just set the boot partition type as EF instead of EF00.


This is right, but with some motherboard there is some troubles to use MBR with UEFI, by using GPT you are sure that works properly. I read a notice about that on the Arch Wiki but actually I did not find anymore this information...


Edit : according to the Gentoo wiki
Create a partition of type "EFI System partition", which is EF00 on GPT and EF on MBR
_________________
Macbook Pro Unibody 9.1 - Kernel 4.4.6 - Awesome 3.5
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7550
Location: Goose Creek SC

PostPosted: Mon Feb 01, 2016 9:56 pm    Post subject: Reply with quote

From the UEFI specification, "In addition, partition support for MBR, GPT, and El Torito must be implemented." You are right and I am wrong. Sorry for the static.
_________________
Defund the FCC.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3383

PostPosted: Tue Feb 02, 2016 12:05 am    Post subject: Reply with quote

Out of curiosity,
1 - If you've set your EFI system up to directly boot the properly-named kernel
2 - You've just built a new kernel and given it the correct name, and of course only one kernel can have that golden name
3 - You made a mistake somewhere, or I did, and the kernel won't boot

How do you recover?
At least with some sort of boot manager you can always boot the previous working kernel.
_________________
.sigs waste space and bandwidth
Back to top
View user's profile Send private message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Tue Feb 02, 2016 12:30 am    Post subject: Reply with quote

Happiness!!! The procedure in my original post worked perfectly and I'm now booting pure-UEFI.

A note about frame buffers:

My frame buffer when booting UEFI was low resolution. This is odd as efifb is supposed to use the native resolution of the monitor (as long as the graphics card can handle it).

Turned out uvesafb was messing something up. Both efifb and uvesafb activated and tried to make frame buffers.

I recompiled my kernel without uvesafb and now I get a glorious 1920x1080 console. No kernel parameters or anything.
Back to top
View user's profile Send private message
zwede
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2006
Posts: 103

PostPosted: Tue Feb 02, 2016 12:35 am    Post subject: Reply with quote

depontius wrote:
Out of curiosity,
1 - If you've set your EFI system up to directly boot the properly-named kernel
2 - You've just built a new kernel and given it the correct name, and of course only one kernel can have that golden name
3 - You made a mistake somewhere, or I did, and the kernel won't boot

How do you recover?
At least with some sort of boot manager you can always boot the previous working kernel.


You place your new kernel in the /efi/boot directory and give it some new name (not the magix bootx64.efi).

So if you called your new kernel "kernel", you add an entry to the UEFI boot menu with:

efibootmgr --create --label "My new kernel" loader '\efi\boot\kernel'

Yeah, it uses backslashes. It's a microsoft world.

Of course you must do this before rebooting to a single, broken, kernel. If you DID reboot into that broken kernel the only way out of that would be to boot off a live distro and rescue your system that way.
Back to top
View user's profile Send private message
Syl20
Guru
Guru


Joined: 04 Aug 2005
Posts: 564
Location: France

PostPosted: Tue Feb 02, 2016 1:03 pm    Post subject: Reply with quote

1clue wrote:
This is not correct. My EFI partition is 512M type EF00, formatted as FAT32 and mounted as /boot. It contains grub and its associated stuff as well as my EFI stuff.

EFI does not care where you mount it when you're up and running, it only cares that files it expects are where they should be with reference to the EF00 partition, and that the EF00 partition be formatted FAT32.

The OP said he wanted to do without grub, I don't know how to do that but my grub is at /boot/EFI/BOOT/bootx64.efi.

I don't intend to take this off into another direction, but wanted to clear up an error for others who read this thread.

Ok, my bad. Thank you for correcting my mistake.
I just wondered if UEFI (which is not always well implemented) was able to read grub's paths. It seems it is.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum