English / Deutsch | Print version Plop Linux  

<< Previous
32-bit with 64-bit system

Table of Contents

Next >>
Grub2 - BIOS

EFI - General remarks, Kernel, efibootmgr, Grub2


Just some information about EFI.


General remarks


The EFI boot manager searches through FAT partitions for boot files. A default path/file is

/efi/boot/bootx64.efi

On hard disks, a GUID Partition Table is used for the partitions. Usually, the first partition has the partition ID EF00 (EFI System), is a FAT partition with about 300 MB, FAT32 formatted, with the OS boot files.

With Linux, you can configure the EFI boot settings with the program 'efibootmgr'.

To boot Linux you can use either a boot manager like Grub2 or you can boot directly the Linux Kernel with EFI.


Direct Linux Kernel Boot


To boot directly a Linux Kernel with EFI, you have to configure two options in the Kernel config. You have to set 'EFI stub support' and the 'Built-in kernel command line'.

Compile a fresh Kernel:

  • Extract the Linux Kernel Source Code and change into the extracted directory.
  • Grab the current config with 'zcat /proc/config.gz > .config'.
  • Start the configuration menu with 'make menuconfig'.
  • Change into 'Processor type and features'.
  • Change 'EFI runtime service support' to '[*]'.
  • Change 'EFI stub support' to '[*]'.
  • Change (at the bottom of the menu) 'Built-in kernel command line' to '[*]' and set the value to 'root=/dev/sda2' when Linux is installed on that partition.
  • Exit and save the changes.
  • Compile with 'make bzImage'.

Copy 'bzImage' (when fresh compiled, then from arch/x86/boot/bzImage) to the directory '/efi/boot' on the EFI partition.

When you rename 'bzImage' to 'bootx64.efi', then the EFI boot manager will automatically detect the kernel.

Use 'efibootmgr' to configure the EFI boot manager. Example to add a new entry to boot the file 'bootx64.efi':

efibootmgr -c -d /dev/sda -p 1 -L "Plop Linux" -l "\efi\boot\bootx64.efi"
You have to use the backslash here!


efibootmgr


You can configure the boot entries of your EFI system with this program. Use 'efibootmgr -h' to list all program options.


List boot entries

efibootmgr or efibootmgr -v

Output with -v:

BootCurrent: 0001
Timeout: 3 seconds
BootOrder: 0000,0002
Boot0000* Plop Linux	HD(1,GPT,7fda9dd2-426e-42eb-a37d-fdb42d5d8eb8,0x800,0x100000)/File(\EFI\BOOT\BOOTx64.EFI)
Boot0001* Some OS	HD(1,GPT,7fda9dd2-426e-42eb-a37d-fdb42d5d8eb8,0x800,0x100000)/File(\EFI\BOOT\OTHER.EFI)
Boot0002* Grub	HD(1,GPT,7fda9dd2-426e-42eb-a37d-fdb42d5d8eb8,0x800,0x100000)/File(\EFI\BOOT\GRUB.EFI)


Add menu entry and set as default boot

Example 1: efibootmgr -c -d /dev/sda -p 1 -L "Plop Linux" -l "\efi\boot\bootx64.efi"

Example 2: efibootmgr -c -d /dev/sda -p 1 -L "Grub" -l "\efi\boot\grub.efi"

-c: Create a new entry
-d: Device with the boot file
-p: Partition number
-L: Label
-l: File with the full path. You have to use the backslash here!

The new entry will be automatically the default boot.


BootOrder - Set boot sequence

List the entries with 'efibootmgr'.

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0002
Boot0000* Plop Linux
Boot0001* Some OS
Boot0002* Grub

Change to Grub as first and Plop Linux as second: efibootmgr -o 2,0

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0002,0000
Boot0000* Plop Linux
Boot0001* Some OS
Boot0002* Grub

The numbers 0, 2 are from Boot0000, Boot0002.


Delete entry

Example: Delete the entry 'Boot0001* Some OS'

List the entries with 'efibootmgr'.

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0002
Boot0000* Plop Linux
Boot0001* Some OS
Boot0002* Grub

Delete: efibootmgr -Bb 1

BootCurrent: 0000
Timeout: 3 seconds
BootOrder: 0000,0002
Boot0000* Plop Linux
Boot0002* Grub

The number 1 is from Boot0001.


Grub2


Prepared package for the EFI partition: Download efi.tar.gz

Config file: /efi/grub/grub.cfg

Generate Grub2 bootx64.efi: grub-mkstandalone -O x86_64-efi -o /boot/efi/boot/bootx64.efi
The EFI partition is mounted to '/boot'.




<< Previous
32-bit with 64-bit system

Table of Contents

Next >>
Grub2 - BIOS


© 2024 by Elmar Hanlhofer