Efibootmgr

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Efibootmgr and the translation is 14% complete.
Outdated translations are marked like this.

La aplicación efibootmgr interactúa con el firmware UEFI del sistema. Es una herramienta popular para manipular los ajustes EFI a fin de crear y gestionar entradas de arranque capaces de arrancar Línux (o cualquier otro sistema operativo EFI).

La aplicación sys-boot/efibootmgr no es un cargador de arranque. Se trata de una herramienta que interactúa con el firmware EFI del sistema, el cual actúa como un cargador de arranque. Si se utilizar efibootmgr se pueden crear, editar, reordenar y eliminar entradas de arranque.

Núcleo

CONFIG_EFIVAR_FS support needs to be enabled.

Nota
It is not possible to use efivarfs without the EFI runtime services, which (in case they have been disabled by default, i.e. CONFIG_EFI_DISABLE_RUNTIME=y) can also be enabled by the kernel command-line option efi=runtime.

Emerge

El paquete sys-boot/efibootmgr no tiene ningún ajuste USE. Todo lo que se necesita es instalarlo:

root #emerge --ask sys-boot/efibootmgr

Configuración

Variables EFI

Para utilizar correctamente efibootmgr, se debe poder acceder al sistema de ficheros de las variables EFI. Esto requiere que se haya iniciado el sistema en modo EFI (y no a través del modo MBR del firmware), de lo contrario no se podrá acceder a las variables EFI. Si el sistema está en modo MBR, reiniciar y hacer todo lo necesario para indicarle al firmware que se debe iniciar en modo EFI. Normalmente esto implica cambiar una opción en la configuración del firmware o seleccionar una entrada de arranque EFI en el menú de inicio del sistema.

Cuando el sistema está en modo EFI, lanzar la siguiente orden para comprobar la existencia de efivarfs:

root #mount | grep efivars
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)

Si la partición efivars no está montada (que ha debido montarse a través del guión de inicio sysfs), es posible montarla manualmente utilizando la siguiente orden:

root #mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Precondiciones

Si no existe una sistema de particiones EFI (ESP), se necesitará crear uno, leer EFI System Partition

Utilización

Listar las entradas de arranque

Para listar las entradas de inicio actuales se puede utilizar la opción --verbose (-v):

root #efibootmgr -v
BootCurrent: 0002
Timeout: 3 seconds
BootOrder: 0003,0003,0002,0000,0004
Boot0000* CD/DVD Drive  BIOS(3,0,00)
Boot0001* Hard Drive    BIOS(2,0,00)
Boot0002* Gentoo        HD(1,800,61800,6d98f360-cb3e-4727-8fed-5ce0c040365d)File(\EFI\boot\bootx64.efi)
Boot0003* Hard Drive    BIOS(2,0,00)P0: ST1500DM003-9YN16G

Crear una entrada de arranque

Para crear una entrada de arranque EFI, pasaremos un par de argumentos a efibootmgr:

  • --create (-c) para crear una nueva entrada;
  • --part (-p) seguido por el número de partición en la que se aloja la partición EFI System Partition;
  • --disk (-d) seguido por el disco en el que se aloja la partición EFI System Partition;
  • --label (-L) seguida de la etiqueta que vamos a utilizar como entrada de arranque;
  • --loader (-l) seguido de la ruta a la imagen EFI para arrancar.
Importante
La ruta de la imagen de EFI a arrancar debe usar barra invertida (\), en lugar de la barra diagonal (/), como separador de ruta.
Importante
Additionally, if the ESP was already created by another OS, it might be named differently than /efi/EFI. If an ESP was created by another OS, begin the EFI Boot entry using this directory name, which immediately follows /efi.

Below are some examples of how a UEFI entry can be created. If this is the folder structure:

root #tree /efi/ -L 3
/efi/
└── EFI
    ├── Grub
    │   └── grubx64.efi
    └── Gentoo
        └── bzImage.efi

then the loader paths will be:

root #efibootmgr -c -L "Grub" -l '\EFI\Grub\grubx64.efi'
root #efibootmgr -c -L "Gentoo" -l '\EFI\Gentoo\bzImage.efi'

Por ejemplo:

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

It is also possible to add parameters – maybe not supported by all UEFI implementations[1] - to the kernel's command line:

root #efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l '\efi\boot\bootx64.efi' -u 'root=/dev/sda3 initrd=\efi\boot\initramfs.img quiet'

Opcionalmente, se pueden instalar núcleos adicionales e informar de su existencia al firmware UEFI. Esto es especialmente útil cuando queremos probar más de un núcleo o realizar un arranque dual con otro sistema operativo. Esto se mostrará en el símbolo de espera de órdenes de la selección de arranque, normalmente después de que una tecla con funciones especiales del teclado se ha pulsado durante la inicialización del sistema. La última entrada añadida tiene siempre al prioridad más alta por lo que será la opción por defecto. Si se desconoce la combinación especial de teclas durante la inicialización, se puede buscar en la documentación oficial del fabricante del computador. De hecho, esta información no es muy difícil de encontrar.

Eliminar una entrada de arranque

Antes de eliminar una entrada, primero debemos averiguar qué identificador (ID) tiene la entrada.

Para eliminar, por ejemplo, la entrada de Gentoo que se muestra arriba (que tiene Boot0002 como identificador), le indicaremos a efibootmgr que elimine la entrada con el identificador 2, para lo cual le pasaremos los argumentos --bootnum (-b) seguido del identificador, y --delete-bootnum (-B) para eliminar la entrada en cuestión:

root #efibootmgr -b 2 -B

Removable media

EFI bootloaders on removable media are not configured as boot entries, so tools like efibootmgr are not required. Instead the computer firmware identifies removable boot options by looking for a predefined file name unique to the system architecture in use, in a predefined path.[2]

Some (U)EFI implementations support the use of the removable media boot path as a fallback on internal drives.[3] This is against specification and should be avoided, but may help on a system with a buggy (U)EFI. Only one such fallback bootloader is possible on a specific system (i.e. architecture), due to the standardized boot path and file names.

Architecture Abbreviation File name PE executable machine type
x86 32-bit IA-32 \efi\boot\bootia32.efi 0x14c
x86-64 x64 \efi\boot\bootx64.efi 0x8664
Itanium IA-64 \efi\boot\bootia64.efi 0x200
ARM 32-bit AArch32 \efi\boot\bootarm.efi 0x01c2
ARM 64-bit AArch64 \efi\boot\bootaa64.efi 0xAA64
RISC-V 32-bit \efi\boot\bootriscv32.efi 0x5032
RISC-V 64-bit \efi\boot\bootriscv64.efi 0x5064
RISC-V 128-bit \efi\boot\bootriscv128.efi 0x5128
Loongson 32-bit LoongArch32 \efi\boot\bootloongarch32.efi 0x6232
Loongson 64-bit LoongArch64 \efi\boot\bootloongarch64.efi 0x6264
Nota
To boot from removable media, the firmware has to look for compatible bootloaders on supported devices, which can be configured in the firmware setup. Like most firmwares, (U)EFI provides a hotkey to show a boot selection (formally known as "BIOS Boot Selection" or BBS), otherwise (U)EFI will use the configured default boot entry. However, a buggy (U)EFI may default to the removable media boot path even on internal drives.

To use the removable media boot path it is sufficient to copy the EFI bootloader to the required path and file name. Should the firmware make use of this fallback, this may also remove the ability to select between configured boot entries, meaning that boot options (as listed with efibootmgr) through (U)EFI will not work. Even though every EFI bootloader can be used as fallback, it may be advisable to use a boot manager that itself has the ability to select between boot options, such as GRUB. From the above example for x64 (amd64):

root #cp /efi/EFI/Grub/grubx64.efi /efi/EFI/boot/bootx64.efi
Nota
The FAT file system of the EFI System Partition is not case-sensitive, but case-preserving (VFAT), while Unix and Linux is strictly case-sensitive at all times. Because of this, the path /efi/EFI/boot/bootx64.efi may not work on all systems, as it could be using capital letters, e.g. /efi/EFI/BOOT or /efi/EFI/Boot; the same goes for bootx64.efi. Running tree -L 3 /efi, when the ESP is mounted under /efi, will show the names in use on the individual system, to which the above command has to be changed accordingly.
Importante
The fallback bootloader is not automatically updated! Every time e.g. GRUB is re-installed (like after a version update, which may contain security fixes), it has to be copied to the fallback boot path again, overwriting (updating) the previous version!

The boot manager included in systemd, systemd-boot (formally Gummiboot), will automatically install to the removable media boot path. When sys-apps/systemd with the boot USE flag is updated, it is necessary to run bootctl again in order to update both bootloader files.

root #bootctl update

Eliminación

Desinstalación

root #emerge --ask --depclean --verbose sys-boot/efibootmgr

Véase también

  • rEFInd — a boot manager for EFI and UEFI platforms forked from and successor to rEFIt.
  • EFI stub kernel, este artículo explica cómo configurar el núcleo de Línux para poder arrancarlo directamente desde EFI
  • Alternativa 2: efibootmgr en el Manual de Gentoo

References