Módulo EFI (EN PROCESO DE TRADUCCIÓN)
- CONFIG_PM_STD_PARTITION for hibernation
Este artículo describe el módulo de EFI en el kernel, es decir, que el kernel se inicie directamente desde la UEFI.
Un Módulo de EFI (también conocido como Arranque de STUB de EFI ) [1] como un kernel que también es un ejecutable de EFI, es decir, que es directamente iniciado directamente desde el firmware de la UEFI. Esto significa que en este caso no es necesario un cargador de arranque. (Pero es posible instalarlo de todos modos.)
Configuración del kernel
Soporte de el módulo de EFI
La siguientes opciones de la configuración del kernel deben de ser activadas:
Processor type and features --->
[*] EFI runtime service support Search for <code>CONFIG_EFI</code> to find this item.
[*] EFI stub support Search for <code>CONFIG_EFI_STUB</code> to find this item.
[ ] EFI mixed-mode support (OPTIONAL) Search for <code>CONFIG_EFI_MIXED</code> to find this item.
El soporte del modo EFI mixto es solo requerido para iniciar un kernel de 64 bits desde un firmware de 32 bits si el procesador soporta el modo de 64 bits y el modo de entrega de EFI está activado.
Instalación
Si una EFI System Partition (ESP) no existe, por favor sigue los pasos de para crearla antes de esto.
Automatizado
Las implementaciones UEFI varían mucho entre vendedores, así que el arranque usando el módulo EFI tal vez no funcione en todas las versiones de UEFI. Asegurate de tener un metodo secundario de arranque antes de intentar el arranque usando el módulo EFI.
El arranque automatizado usando el módulo de EFI está manejado por el paquete sys-kernel/installkernel-38 y más tarde cuando el valor USE efistub esté habilitado. Esto cambia el esquema de inicio, que inicialmente estaba en /boot a la carpeta EFI/Gentoo en el EFI System Partition
kernel-install usando Systemd
Cuando los valores USE efistub y systemd estén habilitados en el paquete sys-kernel/installkernel , kernel-install llama kernel-bootcfg desde app-emulation/virt-firmware para añadir o remover una entrada de arranque para el kernel instalado o desinstalado. Installkernel es llamado automáticamente por la herramienta del kernel make install o por la fase de después de la instalación de el Distribution Kernels' . Así que no hace falta ningún tipo de acción especial cuando instalas una versión del kernel nueva, aunque debería de ser activado el servicio kernel-bootcfg-boot-successful de el paquete app-emulation/virt-firmware para automáticamente escribir una entrada para la nueva versión de el kernel de forma permanente para que se pueda iniciar correctamente.
Para sistemas usando systemd:
root
#
systemctl enable --now kernel-bootcfg-boot-successful.service
Para sistemas usando OpenRC
root
#
rc-update add kernel-bootcfg-boot-successful default
Cuando la imagen de el kernel que aún necesitamos registrar no es una Unified Kernel Image , la línea de comandos del kernel para la nueva entrada es leída desde:
- /etc/kernel/cmdline , o
- /usr/lib/kernel/cmdline , o
- /proc/cmdline
En este orden. Además, el argumento initrd= de la línea de el comando de el kernel es automáticamente añadido si un initramfs fue generado mientras se instalaba el kernel. Si el aún no registrado kernel es un Unified Kernel Image no necesitamos ninguna clase de comandos especiales para la nueva entrada. En vez de eso, el contenido de esta línea de comandos también son leídos desde los mismos archivos cuando el UKI es generado.
La línea de comandos del kernel, además que el initramfs, también puede ser incluido dentro del kernel, observa las secciones que se encuentran abajo para más información.
La instalación normal del installkernel
Cuando el valor USE efistub está habilitado en el paquete sys-kernel/installkernel , pero el valor USE systemd está desactivado, Installkernel ejecuta la instrucción uefi-mkconfig del paquete sys-boot/uefi-mkconfig para ir dinámicamente actualizando la configuración UEFI. Si el ejecutable de EFI shim está presente en la misma carpeta que la imagen de el kernel, el kernel será descargado vía Shim.
Manual
Es recomendable crear carpetas separadas dentro de /efi/EFI , asumiendo que la ESP está montada en la carpeta /efi . Con el kernel configurado con el soporte de el módulo de EFI, debes de crear una carpeta separada dentro de /efi/EFI :
root
#
mkdir -p /efi/EFI/ejemplo
En algunos sistemas la combinación /efi/EFI o /efi/efi (en minúscula) tal vez ya exista (eso si asumimos que ESP está montado en /efi ). El sistema de archivos FAT de la EFI System Partition (ESP) no le importan las mayúsculas o minúsculas, pero la versión (VFAT) si lo es. Con las opciones por defecto de montado de VFAT los comandos van a funcionar en ambos casos. Deberias de ver el apartado de la sección de la distinción entre mayúsculas y minúsculas en el artículo de FAT para más detalles.
El kernel es creado desde la carpeta del kernel en la que estás ahora y debe de ser copiado a una carpeta nueva. Este comando instalara el kernel a /efi/EFI/example/bzImage.efi :
/usr/src/linux #
make && make modules_install && cp arch/x86/boot/bzImage /efi/EFI/ejemplo/bzImage.efi
Es muy recomendado mantener una versión antigua de el kernel que funciona cuando lo actualizas:
user
$
tree -L 3 /efi
/efi
└── EFI
└── ejemplo
├── bzImage-6.1.67.efi
└── bzImage-6.1.70.efi
La configuración de la partición root
In order to boot directly from UEFI , the kernel or its initramfs needs to know where to find the root partition of the system to be booted. When using a bootmanager like grub the kernel gets its information where to find its root partition from the bootmanager via command line parameter. When using a stub kernel two options can be used to give the kernel this information - choose one of these options:
Option 1: Configuring it into the kernel
Processor type and features --->
[*] Built-in kernel command line
(root=PARTUUID=adf55784-15d9-4ca3-bb3f-56de0b35d88d ro)
{{{1}}}
Option 2: Configuring it into UEFI
To add an entry with kernel command line arguments:
root
#
efibootmgr --create --disk /dev/sda --label "Módulo EFI de gentoo" --loader "\EFI\ejemplo\bzImage.efi" -u "root=/dev/sda3"
Setting the root location using a PARTUUID , or (filesystem) UUID when using a initramfs, is generally preferable and less error prone.
Más ejemplos pueden ser encontrados en Creating a boot entry .
Opcional: Kernel con initramfs
When using a kernel with an external initramfs (as CPIO archive) additional steps are necessary. There is always an initramfs file when building a dist-kernel or when using genkernel. When using a dist-kernel this initramfs is named "initrd" and is in /usr/src/linux-6.1.57-gentoo-dist/arch/x86/boot/initrd . This file must must be copied also into the ESP :
root
#
cp /ruta/a/mi/initramfs/myinitrd.cpio.gz /efi/EFI/ejemplo/initrd.cpio.gz
Now the kernel needs the information where to find it, and the initramfs needs the information where to find its root partition. UEFI must give both information:
root
#
efibootmgr -c -d /dev/sda -p 1 -L "Módulo EFI de Gentoo" -l '\EFI\ejemplo\bzImage.efi' -u 'root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx initrd=\EFI\ejemplo\initrd.cpio.gz'
Un foro explica esto en mayor detalle. Además resolvió algunos problemas que tenían los usuarios:
Forums topic - Booting UEFI without Grub
When using Early Userspace Mounting the Generating the Initramfs and Using a Stub Kernel sections explains it in more detail.
Opcional: initramfs incluido en el kernel
It's also possible to embed the initramfs directly into the kernel. Advantages include the initramfs being verified by Secure Boot when it verifies the kernel, a simplified boot process and EFI partition, and it being easier to load the kernel by hand (because callers no longer need to specify the initramfs). Disadvantages are reduced flexibility, the ease of making a mistake, and using an unconventional boot setup.
If your initramfs contains Microcode , then it is critical for security that it is receiving updates. When embedded, the initramfs can't be updated independently of the kernel, and a kernel rebuild will be necessary every time the initramfs is updated . In particular, please ensure that:
-
If
is not being run before rebuilding the kernel,
root #make cleanis run to clear the cached initramfs CPIO archive that remains from the last build.root #rm usr/initramfs_data.cpio - When the initramfs has an update, the kernel is rebuilt and reinstalled.
- If the initramfs is managed by sys-apps/portage , the initramfs is updated before the kernel.
The kernel supports both CPIO files (for example, as produced by Dracut ) and source directories which are to be compressed into a CPIO archive. The following shows the latter with /usr/src/initramfs , however should be substituted with /path/to/my/initramfs/myinitrd.cpio.gz if the former case is desired (it usually is, unless you are using a Custom Initramfs ).
General Setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/usr/src/initramfs) Initramfs source file(s)
Configuración del firmware EFI
Para asegurarse de que todo esté funcionando correctamente, el kernel debe de ser iniciado sin el argumento initrd .
Para crear la entrada de la imagen de el kernel unificado:
root
#
efibootmgr --create --disk /dev/sda --label "Módulo EFI de Gentoo" --loader "\EFI\ejemplo\bzImage.efi"
Kernel backup
It is recommended to always have a backup kernel. If a bootmanager like grub is already installed, it should not be uninstalled, because grub can boot a stub kernel just like a normal kernel. A second possibility is to work with an additional UEFI entry. Before installing a new kernel, the current one can be copied from /efi/EFI/ejemplo/ to /efi/EFI/backup. The second UEFI entry was also created with efibootmgr . In this example, other names were used: (Pendiente de traducir)
root
#
efibootmgr
BootCurrent: 0002 Timeout: 1 seconds BootOrder: 0002,0000,0001 Boot0000* Secure HD(1,GPT,0adcbfee-21aa-42ea-9a9a-2e53bd05e6a2,0x800,0x7f800)/File(\EFI\secure\bzImage.efi) Boot0001* gentoo HD(1,GPT,0adcbfee-21aa-42ea-9a9a-2e53bd05e6a2,0x800,0x7f800)/File(\EFI\gentoo\grubx64.efi) Boot0002* Backup HD(1,GPT,0adcbfee-21aa-42ea-9a9a-2e53bd05e6a2,0x800,0x7f800)/File(\EFI\backup\bzImage.efi)
Carga de micro código
Cuando uses un kernel sin initramfs es muy recomendado cargar el micro código descrito en los siguientes artículos:
Opcional: Activando el Arranque Seguro
Si vas a activar en este kernel el Secure Booting , debe de ser activado con la herramienta sbsign , que te la proporciona el paquete app-crypt/sbsigntools :
root
#
sbsign --key {db key} --cert {db cert} /efi/EFI/ejemplo/bzImage.efi
Más información está disponible en Secure Boot .
It is not possible to EFI Stub boot via sys-boot/shim due to the vanilla EFI Stub missing the required .sbat sbat section. As such the used signing keys must be registered directly with the UEFI firmware to EFI Stub boot with Secure Boot enabled. See the Unified Kernel Image wiki page for an alternate EFI Stub booting method that does support booting via shim .
Problemas comunes
Some rare (U)EFI implementations do not accept individual EFI entries. In this case it often works to use the removable media boot path , see EFI System Partition #removable media for details. E.g. this command will copy the kernel for a 64 bit UEFI:
root
#
cp /usr/src/linux/arch/x86/boot/bzImage /efi/EFI/boot/bootx64.efi
- Older kernels compiled with gcc:10 crashed at boot ( bug #721734#c4 ).
-
Usuarios de el paquete
sys-kernel/gentoo-kernel-bin
pueden especificar la ruta de la partición root con el parámetro
root=usando el paquete efibootmgr :
root
#
efibootmgr -c -L "Gentoo Linux" -l '\EFI\Gentoo\bootx64.efi' -u 'root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
- Para crear una entrada boot con efibootmgr y hibernación en la partición swap:
root
#
efibootmgr -c -L "Gentoo Linux" -l '\EFI\Gentoo\bootx64.efi' -u 'root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX resume=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
Vista recomendada
- UEFI — a firmware standard for boot ROM designed to provide a stable API for interacting with system hardware. On x86 it replaced the legacy BIOS .
- Efibootmgr — herramienta popular para manipular los ajustes EFI a fin de crear y gestionar entradas de arranque
- Architecture specific kernel configuration (AMD64 Handbook)
- REFInd — a boot manager for UEFI platforms.
- Unified Kernel Image — a single executable which can be booted directly from UEFI firmware , or automatically sourced by boot-loaders with little or no configuration.
Recursos externos
- Linux Kernel Documentation on EFI Stub
- EFI Stub - booting without a bootloader El blog del que este artículo está parcialmente basado
- EFI bootloaders Una lista de alternativas para iniciar un sistema (U)EFI.
- Gentoo Forums: Suspend and Hibernate with UEFI
- http://www.kroah.com/log/blog/2013/09/02/booting-a-self-signed-linux-kernel/