Genkernel

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Genkernel and the translation is 34% complete.
Outdated translations are marked like this.
Not to be confused with gentoolkit.
Advertencia
genkernel is unmaintained; documentation presented here may be incomplete and may not reflect the current state of Gentoo tooling. Users encountering issues with genkernel will be asked to use another tool. Please see the Distribution kernel section in the Handbook for a supported alternative.

genkernel es una herramienta creada por Gentoo que se utiliza para automatizar el proceso de construcción del núcleo e initramfs. Algunas de las características generales incluyen:

  • Configurar los ficheros fuente del núcleo.
  • Construir el núcleo comprimido bzImage y copiarlo a /boot.
  • Crear un initramfs y copiarlo a /boot.
  • Crear enlaces simbólicos en /boot.
  • Añadir código del usuario al initramfs tal como ficheros de cifrado, imágenes de inicio (spla.github.io/sh), módulos añadidos y demás.
  • Comprimir el initramfs.
  • Configurar el Gestor de arranque para arrancar el núcleo e initramfs recientemente creados.
Nota
To use /efi instead of /boot for newer UEFI systems, see Changing the boot directory to /efi.
Nota
Un malentendido común es creer que genkernel generará automaticamente una configuración personalizada del núcleo. genkernel automatiza el proceso de construcción del núcleo y construye el initramfs, sin embargo no genera un fichero personalizado de configuración del núcleo. Utiliza un fichero genérico de configuración del núcleo que ofrece soporte para subsistemas utilizados comúnmente basándose en una arquitectura específica. Los detalles se pueden consultar en el repositorio del proyecto. Seleccionar la arquitectura y a continuación el fichero de configuración del núcleo.

Instalación

Ajustes USE

USE flags for sys-kernel/genkernel Gentoo automatic kernel building scripts

+firmware Prefer system firmware sys-kernel/linux-firmware over local copy.
ibm Add support for IBM ppc64 specific systems
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
Data provided by the Gentoo Package Database · Last update: 2026年07月29日 05:17 More information about USE flags

Emerge

Lance la instalación de genkernel:

root #emerge --ask sys-kernel/genkernel

Utilización

La forma general de invocar a genkernel se muestra a continuación:

root #genkernel [opciones ...] acción

Opciones

El comportamiento actual de genkernel depende de un gran número de opciones, la mayoría de las cuales se pueden activar o desactivar en el fichero /etc/genkernel.conf o pasarse a través de la orden genkernel en cada invocación. La opciones que se pasan como parámetros a la orden son preferentes a las definidas en /etc/genkernel.conf. El fichero de configuración está muy bien documentado, sin embargo, algunas de las opciones más usadas se explorarán en este artículo. El objetivo es que el lector se familiarice con las invocaciones comunes de genkernel. Para obtener explicaciones más completas, lea los comentarios en el propio fichero /etc/genkernel.conf o la salida de la orden man genkernel.

Nota
Algunas de las opciones tienen una variante que desencadena un comportamiento contrario. Se define como --[no-]nombre_de_opción, y este comportamiento se muestra entre corchetes tal y como se ve en el siguiente ejemplo:
CÓDIGO Habilita o deshabilita cierta opción
--[no-]menuconfig : Activa [Desactiva] ...
Allí donde las opciones tengan únicamente un efecto negativo, el no- y su efecto, que no son opcionales en este caso, se muestran sin corchetes.
CÓDIGO Enable or disable a certain option
--[no-]menuconfig : Activates [deactivates] ...

Where options have only a negative effect, the no-, and its effect, which are not optional in this case, are figured without square brackets. }}

Opciones que actúan en la interactividad del usuario

Las opciones de configuración listadas abajo ayudan al usuario a decidir cómo interaccionar con el proceso de configuración. Los usuarios pueden incluso escoger si el archivo de configuración creado en el proceso se debería guardar o no. La siguientes opciones de configuración se consideran principales:

--config=/path/to/genkernel.conf
Points to the Genkernel configuration file to use (defaults to /etc/genkernel.conf).
--kernel-config=/path/to/kernel.config
Points to the kernel configuration file to use. To re-use the kernel configuration from the currently running kernel, it is possible to specify /proc/config.gz if it exists. By default, genkernel uses the config from the previous build of the same kernel version or a default kernel config if there isn't a previous config. Use the special value default to force usage of genkernel's generic kernel config. This location must not be /usr/src/linux/.config as it risks being lost or causing errors.
--[no-]menuconfig
Activates (or deactivates) the make menuconfig command (which invokes an interactive configuration menu) before building the kernel.
--gconfig
Provides a kernel configuration utility which depends on the GTK libraries. The advantage of this option is that most users find it easier and clearer to configure the kernel using this tool, since it relies on the X-windowing system. The disadvantage of this option is that the X-windowing system is required to use it, so it will not work on the command line.
--xconfig
Provides a kernel configuration utility which depends on the QT libraries. The advantage of this option is that most users find it easier and clearer to configure the kernel using this tool, since it relies on the X-windowing system. The disadvantage of this option is that the X-windowing system is needed to use it, so it will not work on the command line.
--[no-]save-config
Saves [or does not save] the kernel configuration to a file in the /etc/kernels directory for later use.
--kernel-append-localversion=-mycfg42
Allows the modification of kernel's LOCALVERSION value which will affect kernel's and and initramfs' filename in /boot and modules in /lib/modules/ directory. This is especially helpful to build a new independent revision with its own kernel binary, initramfs and modules. The example above, with =sys-kernel/gentoo-sources-5.4.2, would create /boot/vmlinuz-5.4.2-gentoo-x86_64-mycfg42, /boot/initramfs-5.4.2-gentoo-x86_64-mycfg42.img and /lib/modules/4.19.88-gentoo-x86_64-mycfg42 on amd64 with default settings.

Opciones que afectan al sistema resultante

Las opciones de configuración mostradas aquí, definen qué características podrán ser o no se activadas en el núcleo e initrd resultantes.

--[no-]splash
Activa (o desactiva) el soporte del framebuffer splash Fbsplash en la imagen initrd construida para el núcleo. Para utilizar un tema distinto del que se ofrece por defecto por fbsplash, utilice --splash=TemaPreferido (donde TemaPreferido es el título de uno de los directorios dentro del directorio /etc/splash).
--splash-res=ResoluciónPreferida
Esta opción permite seleccionar qué resoluciones de pantallas para splash se ofrecerán durante el arranque del sistema. Esto es útil por dos razones. En primer lugar se puede seleccionar únicamente la resolución o resoluciones de pantalla relevantes para el sistema. En segundo lugar se puede evitar el incremento innecesario del espacio en disco que se initrd necesita (ya que la imagen initrd no ofrece soporte para las resoluciones que no son relevantes para la configuración del sistema). Sin embargo, esta opción se omite en mejores situaciones, por ejemplo cuando se construye un núcleo para un CD de instalación, esto permite soporte de splash para todas las resoluciones posibles.
--do-keymap-auto
Forzar las selección del mapa del teclado durante el arranque.
--keymap
Habilita la selección de mapa del teclado en el inicio del sistema (por ejemplo, para la entrada de la contraseña de contenedores LUKS). El mapa del teclado deseado se puede pasar como opción de inicio en el valor de keymap (nombre del fichero de mapa del teclado sin .map). Los ficheros de mapa de teclado disponibles se pueden encontrar en /usr/share/genkernel/defaults/keymaps/.
Si el mapa del teclado necesitado no está disponible en genkernel, se puede convertir uno de los mapas de sys-apps/kbd ya existentes (disponibles en /usr/share/genkernel/defaults/keymaps/) utilizando loadkeys --bkeymap. Leer la página del manual de loadkeys para más detalles.
--lvm
Incluye soporte para almacenamiento mediante gestión de volúmenes lógicos (LVM2) desde binarios estáticos si están disponibles en el sistema. Los binarios (estáticos) relevantes LVM2 se compilan si no están disponibles. Asegúrese de instalar el paquete sys-fs/lvm2 en el sistema (emerge sys-fs/lvm2) antes de habilitar esta opción, luego eche un vistazo al artículo sobre LVM en el wiki de Gentoo.
--dmraid
Incluye soporte para DMRAID, la utilidad que crea mapeos RAID utilizando el subsistema de mapeo de dispositivos del núcleo. DMRAID descubre, activa, desactiva y muestra las propiedades de conjuntos de software RAID (por ejemplo ATARAID) y particiones DOS contenidas.
--luks
Incluye soporte para la configuración de clave unificada Linux o LUKS. Esto permite utilizar un dispositivo cifrado por LUKS que contiene el sistema de ficheros. En el cargador de arranque, se configura un dispositivo cifrado en el valor de crypt_root (y root debería ser el dispositivo no cifrado que crea LUKS).
--disklabel
Añade soporte para etiquetas de discos y UUID support en la imagen initrd.
--iscsi
Añade soporte para iSCSI en la imagen initrd.
--multipath
Añade soporte para Multipath a la imagen initrd.
--linuxrc=/ruta/al/fichero/linuxrc
Especifica un archivo linuxrc creado por el usuario, un guión que se inicializa durante la fase de inicialización del núcleo antes de la propia fase de arranque. Se puede encontar un guión linuxrc por defecto en el directorio /usr/share/genkernel/. Este guión permite iniciar en un pequeño núcleo modular que intentará cargar la menor cantidad de controladores (como módulos) necesitados por el sistema.
--cachedir=/ruta/al/directorio/alternativo
Cambia la localización por defecto de la caché que se utiliza cuando se construye el núcleo.
--tempdir=/ruta/al/nuevo/directoriotemporal
Especifica la localización del directorio temporal utilizado por genkernel durante la construcción del núcleo.
--unionfs
Incluye soporte para el sistema de ficheros de unificación en la imagen initrd.
--mountboot
Detecta si se necesita montar o no el directorio /boot en una partición separada. Buscará instrucciones acerca de cómo montar la partición de inicio en un sistema de ficheros en el guión /etc/fstab (si es necesario).
--microcode
Crea un cpio temprano relleno con microcódigo para procesadores Intel/AMD processors para ofrecer soporte temprano para Xen y Linux.
--splash-res=PreferredResolution
This option allows to select which splash screen resolutions will be supported in the initrd during the start-up of the system. This is useful for two reasons. First, to be able to select only the splash screen resolution(s) relevant to the system. Second, to avoid the unnecessary increase in the disk space required by initrd (since the initrd does not have to support resolutions that are irrelevant for the system's configuration.) However, the option is best omitted if the kernel is being compiled for an Installation CD; this allows splash support for all possible resolutions.
--do-keymap-auto
Force keymap selection during the boot sequence.
--keymap
Enables keymap selection at boot (e.g. for LUKS container password input). The desired keymap can be passed in boot options as the value of keymap (name of the keymap file without .map). Available keymap files can be found in /usr/share/genkernel/defaults/keymaps/.
If a needed keymap is not available in genkernel, it is possible to convert one of the existing sys-apps/kbd keymaps (available in /usr/share/genkernel/defaults/keymaps/) using loadkeys --bkeymap. See loadkeys man page for details.
--lvm
Includes support for storage using via Logical Volume Management (LVM2) from static binaries, if available to the system. Relevant (static) LVM2 binaries are compiled when unavailable. Be sure to install the sys-fs/lvm2 package on the system (emerge sys-fs/lvm2) before enabling this option.
--dmraid
Includes support for DMRAID; the utility which creates RAID mappings using the kernel device-mapper subsystem. DMRAID discovers, activates, deactivates and displays properties of software RAID sets (ATARAID, for example) and contained DOS partitions.
--luks
Includes support for Linux Unified Key Setup. This will allow to use a device encrypted by LUKS which contains the root filesystem. On the bootloader, set that encrypted device as the value of crypt_root, and root shall be the unencrypted device LUKS creates ( i.e /dev/mapper/root will be path to mount, and proper boot parameters line will look, like this: GRUB_CMDLINE_LINUX="... crypt_root=UUID=<crypto_LUKS uuid> root=/dev/mapper/root ...").
--iscsi
Adds support for iSCSI to the initrd.
--multipath
Adds support for Multipath to the initrd.
--linuxrc=/path/to/the/linuxrc_file
Specifies a user-created linuxrc — a script that is initialized during the start-up stage of the kernel, prior to the actual boot process. A default linuxrc script can be found in the /usr/share/genkernel/ directory. This script allows booting into a small, modularized kernel; it tries to load the minimum amount of drivers that are needed (as modules) by the system.
--cachedir=/path/to/alt/dir
Overrides the default cache location used while compiling the kernel.
--tmpdir=/path/to/new/tempdir
Specifies the location of the temporary directory used by genkernel while compiling the kernel.
--unionfs
Includes support for the Unification File System in the initrd image.
--mountboot
Detects whether or not the /boot directory needs to be mounted on a separate partition. It will check /etc/fstab script for instructions on how to mount the boot partition on a file system (if needed).
--microcode
Creates an early cpio filled with microcode for Intel/AMD processors for Linux early microcode support.

Opciones que actúan en la elección de las herramientas utilizadas para la construcción

Las siguientes opciones están soportadas por genkernel y se pasan a las aplicaciones relevantes mientras se ensambla el núcleo. Estas opciones afectan a las herramientas de compilación utilizadas en el proceso de compilación del núcleo aunque a un nivel mucho más bajo.

--kernel-cc=someCompiler
Specifies the compiler employed during the kernel compilation process.
--kernel-ld=someLinker
Specifies the linker employed during the kernel compilation process.
--kernel-as=someAssembler
Specifies the assembler employed during the kernel compilation process.
--kernel-make=someMake
Specifies an alternative to the GNU make utility employed during the kernel compilation process.
--utils-cc=someCompiler
Specifies the compiler employed during the compilation of support utilities.
--utils-ld=someLinker
Specifies the linker employed during the compilation of support utilities.
--utils-as=someAssembler
Specifies the assembler employed during the compilation of support utilities.
--utils-make=someMake
Specifies an alternative to the GNU make utility employed during the compilation of support utilities.
--makeopts=-jX
Specifies the number of concurrent threads that the make utility can implement while the kernel (and utilities) are being compiled. The variable X is a number to be freely chosen, although the most common values are obtained by adding one (1) to the number of cores used by the system, or just use the number of cores on the system. So, for a system with one core, most common option values are -j2 or -j1; a system with two cores most likely uses the -j3 or -j2 options, and so on. (A system with one processor that supports Hyper-ThreadingTM (HT) Technology can be assumed to have 2 cores, provided Symmetric Multi-Processing (SMP) support is enabled in the kernel.)

Opciones que actúan en el proceso de compilación

Las siguientes opciones normalmente actúan durante el proceso de compilación:

--kerneldir=/path/to/sources/
Specifies an alternative kernel source location, rather than the default /usr/src/linux/ location.
--kernel-config=/path/to/config-file
Specifies which kernel configuration will be used. By default, genkernel will determine kernel version found in --kerneldir and look for kernel config (KV) in /etc/kernels/kernel-config-$KV. If no kernel configuration was found, genkernel will look for a generic kernel configuration in /usr/share/genkernel/$ARCH. A special value default can be used to force usage of genkernel's generic kernel configuration.
Consejo
Use --kernel-config=/proc/config.gz to start building a new kernel based on kernel configuration from currently running kernel.
Note: This will only work if current active kernel was built with CONFIG_IKCONFIG=y which is normally the case.
--module-prefix=/path/to/prefix-directory/
Specifies a prefix to the directory where kernel modules will be installed (default path is the /lib/modules directory.)
--[no-]clean
Activates (or deactivates) the make clean command before compiling the kernel. The make clean command removes all object files and dependencies from the kernel's source tree.
--[no-]mrproper
Activates (or deactivates) the make mrproper command before kernel compilation. Like the make clean command listed above, make mrproper removes all object files and dependencies from the kernel's source tree. However, any previous configuration files (in /path/to/sources/.config or /path/to/sources/.config.old) will also be purged from the kernel's source tree. If it is undesirable that the kernel's .config file keeps disappearing, be sure to disable this option!
--oldconfig
Issues the make oldconfig command, which attempts to collect configuration information for the system's architecture from a generic script in /usr/share/genkernel. This is a non-interactive process; no user input is entertained. Also, if --oldconfig is used in conjunction with --clean, the latter option is negated, resulting in the activation of the --no-clean option.
--[no-]module-rebuild
Runs, or does not run emerge @module-rebuild to build out-of-tree modules after kernel and kernel modules have been built. This option is enabled by default.
--callback="echo hello"
Calls the specified arguments (echo hello, in this case) after the kernel and the relevant modules have been built, but before building the initramfs.
Nota
Before genkernel-4, this callback was used to trigger rebuild of out-of-tree modules. Since genkernel-4, a dedicated command-line parameter --module-rebuild was introduced, see above.
--[no-]install
Activates (or deactivates) the make install command, which installs the new kernel image, configuration file, initrd image and system map onto the boot partition. Any compiled modules will be installed as well. By default genkernel will attempt mount /boot if it is on a separate partition before running the install command.
--no-ramdisk-modules
Refrains from copying any modules to the genkernel-created initrd image. This option is an exception to the rule about the no- prefix; omission of this prefix creates an invalid genkernel option.
--all-ramdisk-modules
Copies all available modules to the genkernel-created initrd image.
--genzimage
Creates the initrd image, prior to the kernel image (this hack currently applies only to PPC Pegasos systems).

Opciones de depuración

El uso de opciones de depuración durante el proceso de construcción del núcleo controla la cantidad de información que se muestra, así como la presentación de esta información.

--loglevel=<0|1|2|3|4|5>
Controls the level of verbosity for information printed by genkernel. The variable LOGLEVEL is an integer between 0 and 5. The level '0' represents minimal output (=no output), while '5' provides as much information as possible about genkernel's activities during the kernel compilation and initramfs assemble process.
Nota
Genkernel will always log complete output to /var/log/genkernel.log by default. --loglevel only controls output shown on screen.
--logfile=/path/to/output_file
Log file where genkernel outputs to by default. Defaults to /var/log/genkernel.log.
--[no-]color
Activates (or deactivates) colored output.
--[no-]cleanup
Activates (or deactivates) the full post-run cleanup for debug purposes.

Acciones

Una acción enviada a genkernel en la línea de comandos mediante genkernel [opciones ...] acción, le indica a genkernel qué acción debe realizar. Se ofrecen las siguientes acciones:

Action Description
all Builds all stages — the initrd, kernel image and modules.
bzImage Only builds the kernel image.
kernel Only builds the kernel image and modules.
initramfs Only builds the initramfs/ramdisk image.
ramdisk Only builds the initramfs/ramdisk image.

Configuración

Comenzar

Aunque hay varias formas de lanzar genkernel, el enfoque menos intrusivo y recomendado para la mayoría de los usuarios es mediante genkernel all. En este caso se utiliza una configuración genérica que funciona bien en la mayoría de los sistemas. Tal como se mencionaba arriba, este enfoque presenta ciertas desventajas pues la mayor parte de los módulos creados no son útiles para el usuario promedio y puede incrementar el tiempo de compilación. Abajo se muestra un ejemplo de un enfoque más eficiente el cual se logra al pasar ciertos parámetros a genkernel cuando se lanza con el usuario root:

root #genkernel --splash --no-install --no-clean --menuconfig all

La operación descrita arriba provoca que genkernel cree un núcleo con pantalla una pantalla de bienvenida (--splash) que se deberá instalar de forma manual (--no-install). Mientras se prepara el árbol de fuentes del núcleo, genkernel evitará eliminar cualquiera de los archivos objeto preexistentes en el árbol de los fuentes (--no-clean). Se ofrecerá al usuario una herramienta de configuración basada en menús para seleccionar qué módulos se construirán en el sistema (--menuconfig).

Si se reemplaza la opción --no-install por --install se le indicará a genkernel que instale el nuevo núcleo en el directorio /boot de forma automática y se crearán los enlaces simbólicos se se especifica --symlink. El uso de la opción --mountboot le indica a genkernel que monte la partición /boot de forma automática si es necesario.

Nota
No olvide que genkernel lanza el fichero de órdenes /etc/genkernel.conf al comienzo de la construcción, y que cualquier opción definida en él se aplicará excepto cuando se define una opción de línea de órdenes que toma preferencia respecto a la misma opción definida en el fichero anterior.

Changing the boot directory to /efi

It is now recommended to mount the UEFI system boot partition (ESP) under /efi instead of /boot.

By default, the kernel is written to /boot, which used to be the ESP in certain configurations, but is now on the root partition. Reasons to write the kernel to /efi include:

  • Secure Boot expecting a hard coded ESP kernel path
  • Making GRUB2 independent of the root partition for stability or security
  • GRUB2 not supporting the root file-system (bcachefs)
  • Using a grub.cfg not generated by grub-mkconfig


To point genkernel to /efi, either add --bootdir=/efi to the genkernel command or BOOTDIR="/efi" to /etc/genkernel.conf.

ARCHIVO /etc/genkernel.confChanging the boot directory to /efi in /etc/genkernel.conf
# Set the boot directory, default is /boot
BOOTDIR="/efi"

Cambiar el núcleo

Lo primero que se debe hacer es permitir que se lance make menuconfig en el fichero /etc/genkernel.conf:

ARCHIVO /etc/genkernel.confForzar el uso del menú de configuración en /etc/genkernel.conf
# ¿Se lanza 'make menuconfig' antes de compilar este núcleo?
MENUCONFIG="yes"

Gestión de ficheros

Mientras utiliza genkernel, debe tener en cuenta varios aspectos relacionados con su configuración y los ficheros de imagen del núcleo así como la forma en la que el sistema gestiona los fichero fuente del núcleo.

Ficheros fuente

Después de lanzar la orden emerge -u gentoo-sources, siempre que los nuevos fuentes estén disponibles, se creará un nuevo directorio de ficheros fuente del núcleo en /usr/src/ para almacenarlos. Normalmente los fuentes activos del núcleo se definen con el enlace simbólico /usr/src/linux.

El directorio /usr/src debería un aspecto similar a este:

user $ls -l /usr/src
total 16
lrwxrwxrwx 1 root root 19 21 mar 2013 linux -> linux-3.7.10-gentoo
drwxr-xr-x 24 root root 4096 25 ago 10:39 linux-3.10.7-gentoo
drwxr-xr-x 20 root root 4096 21 abr 19:42 linux-3.7.10-gentoo
drwxr-xr-x 21 root root 4096 14 mar 2013 linux-3.7.9-gentoo
 

El enlace simbólico /usr/src/linux se puede cambiar de diferentes formas:

  • Si el ajuste USE symlink está definido, el enlace simbólico /usr/src/linux se actualiza automáticamente para que apunte al los nuevos ficheros fuente instalados.
  • Si el ajuste USE symlink no está definido, el usuario puede cambiar el destino del enlaces simbólico utilizando eselect kernel list seguido de la orden eselect kernel set.

Genkernel utilizará siempre (exclusivamente) los fuentes a lo que apunta el enlace simbólico /usr/src/linux.

Fichero de configuración del núcleo

Si ya se ha realizado una construcción del núcleo con los fuentes activos, debería aparecer un fichero dentro del directorio /etc/kernels que contiene al configuración del núcleo que se ha aplicado mientras se creó la última bzimage del núcleo. Este fichero se llama, por ejemplo, kernel-config-x86_64-3.7.9-gentoo-r1 donde x86_64 sería el nombre de la arquitectura del sistema, 3.7.9 sería la versión de los ficheros fuente utilizados, y r1 la revisión de los fuentes.

Es este fichero kernel-config-x86_64-3.7.9-gentoo-r1 el que se utiliza como configuración cuando se lanza genkernel --menuconfig all.

Si es la primera vez que se lanza genkernel con los nuevos fuentes del núcleo o si no se ha guardado el resultado previo este fichero se sustituye por un fichero de configuración por defecto que se encuentra en usr/share/genkernel/arch/x86_64/kernel-config donde hay que sustituir x86_64 por la arquitectura en la que se está trabajando.

Nota
La ruta a este fichero de configuración por defecto se puede alterar definiendo la variable DEFAULT_KERNEL_CONFIG en el fichero /etc/genkernel.conf.
Guardar la configuración compilada

Si se activa la opción save-config de genkernel, bien desde la línea de órdenes, bien dentro de /etc/genkernel.conf, la configuración del núcleo que se ha compilado se guardará (con el nombre indicado arriba) en el directorio /etc/kernels. Al mismo tiempo, la configuración se guarda en el fichero .config dentro del directorio /usr/src/linux, sin embargo, este fichero no se reutilizará en la siguiente ejecución de genkernel all.

Advertencia
Se debe tener cuidado: Cada vez que se lanza genkernel con la opción save-config activada, el fichero de configuración en /etc/kernels se sobrescribe. Así, se recomienda guardar este fichero con un nuevo nombre antes de lanzar genkernel para conservarlo.
Instalar el núcleo y el initramfs en el directorio /boot

Si se especifica la opción --install cuando se lanza genkernel, se le pedirá a genkernel que instale la imagen del núcleo y el initramfs en el directorio /boot. Para lanzar --install de una forma correcta, defina lo siguiente en el fichero /etc/genkernel.conf:

ARCHIVO /etc/genkernel.confConfigurar el guardado automico del núcleo y el initramfs
# ¿Montar BOOTDIR de forma automática si no está montado?
MOUNTBOOT="yes"
# Guardar la nueva configuración en /etc/kernels
# después de una compilación exitosa
SAVE_CONFIG="yes"
# ¿Crear enlaces simbólicos en BOOTDIR de forma automática?
SYMLINK="yes"
# ¿Añadir el nuevo núcleo a grub2?
#BOOTLOADER="grub2"
  • El primer parámetro no requiere explicación.
  • El segundo parámetro le indica a genkernel que guarde la configuración del núcleo que se ha compilado en /etc/kernels.
  • Las dos últimas opciones le indican a genkernel que actualice automáticamente la configuración de grub. En la práctica sucede lo siguiente:
    • Si existe una imagen previa del núcleo con el mismo nombre, se modifica su nombre añadiendo .old. Un enlace simbólico kernel.old se crea automáticamente apuntando a ella.
    • El nuevo núcleo toma el lugar de cualquier núcleo con el mismo nombre dentro de /boot. Si es la primera vez que se compila un núcleo, se crea automáticamente un enlaces simbólico que apunta al nuevo núcleo.

Después de lanzar genkernel --menuconfig all, el directorio /boot tendrá un aspecto similar al siguiente:

user $ls -al /boot
total 41336
drwxr-xr-x 3 root root 4096 20 abril 17:23 .
drwxr-xr-x 24 root root 4096 15 sept. 12:31 ..
lrwxrwxrwx 1 root root 1 24 febr. 2013 boot -> .
drwxr-xr-x 2 root root 4096 24 febr. 2013 grub
lrwxrwxrwx 1 root root 40 20 abril 17:23 initramfs -> initramfs-genkernel-x86_64-3.7.10-gentoo
-rw-r--r-- 1 root root 1314412 20 abril 17:23 initramfs-genkernel-x86_64-3.7.10-gentoo
-rw-r--r-- 1 root root 1313548 21 marzo 2013 initramfs-genkernel-x86_64-3.7.10-gentoo.old
-rw-r--r-- 1 root root 1295344 25 febr. 2013 initramfs-genkernel-x86_64-3.7.9-gentoo
-rw-r--r-- 1 root root 3310324 25 febr. 2013 initramfs-genkernel-x86_64-3.7.9-gentoo.old
lrwxrwxrwx 1 root root 44 20 abril 17:23 initramfs.old -> initramfs-genkernel-x86_64-3.7.10-gentoo.old
lrwxrwxrwx 1 root root 37 20 abril 17:23 kernel -> kernel-genkernel-x86_64-3.7.10-gentoo
-rw-r--r-- 1 root root 4866656 20 abril 17:23 kernel-genkernel-x86_64-3.7.10-gentoo
-rw-r--r-- 1 root root 4866560 21 marzo 2013 kernel-genkernel-x86_64-3.7.10-gentoo.old
-rw-r--r-- 1 root root 4552288 25 febr. 2013 kernel-genkernel-x86_64-3.7.9-gentoo
-rw-r--r-- 1 root root 3400736 25 febr. 2013 kernel-genkernel-x86_64-3.7.9-gentoo.old
lrwxrwxrwx 1 root root 41 20 abril 17:23 kernel.old -> kernel-genkernel-x86_64-3.7.10-gentoo.old

Configurar el gestor de arranque

extlinux

TODO

GRUB Legacy
Advertencia
The following text is about GRUB Legacy which was removed in Gentoo in February 2019. If at all possible, please migrate to GRUB2 as soon as possible.

Los enlaces simbólicos que se muestran arriba en la configuración del gestor de arranque se pueden utilizar tal cual, incluso cuando el núcleo no se puede arrancar, el usuario siempre podrá arrancar el antiguo.

Para permitir que el núcleo y el initrd ofrecido por genkernel funcione correctamente, deberá ofrecer a su gestor de arranque una información mínima en el fichero de configuración:

  • Añadir real_root=/dev/sdaN, a los parámetros del núcleo que se pasan a la imagen, donde /dev/sdaN apunta a la partición raíz (N es el número de partición si ésta existe).
  • Si está utilizando la pantalla de presentación de arranque (splash), se debe añadir una línea moda adecuada, como por ejemplo pasar vga=0x317 a los parámetros del núcleo y también splash=verbose o splash=silent dependiendo del nivel de detalle que desee a lo largo del proceso de arranque.
  • Añadir la información sobre initrd que requiera la configuración del gestor de arranque. Consulte el capítulo de configuración del cargador de arranque del manual de Gentoo para obtener detallas sobre la configuración del gestor de arranque con initrd.

A continuación se muestra un ejemplo del aspecto que debería tener el fichero grub.conf.

ARCHIVO /boot/grub/grub.confUn fichero ejemplo grub.conf
# Esto es un fichero ejemplo de grub.conf para usar con Genkernel según el manual de Gentoo
# http://www.gentoo.org/doc/es/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2
# Si no está usando Genkernel y necesita ayuda para crear este fichero
# debería consultar el manual. De forma alternativa, consulte el fichero grub.conf.sample
# que se incluye en la documentación de Grub.
default0
timeout5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz
titleGentooLinux
root(hd0,6)
kernel/boot/kernelinitrd=/dev/ram0root=/dev/sda7rootfstype=ext4
initrd/boot/initramfs
titleGentooLinuxoldkernel
root(hd0,6)
kernel/boot/kernel.oldinitrd=/dev/ram0root=/dev/sda7rootfstype=ext4
initrd/boot/initramfs.old
GRUB

TODO

systemd-boot

TODO

Conservar los ficheros de trabajo

La aplicación genkernel guarda automáticamente los cambios realizados en los ficheros. Si se necesita conservar cambios realizados anteriormente se deberán realizar las siguientes acciones.

  • El primer fichero a conservar es la configuración del núcleo en /etc/kernels/. Si los ficheros fuente no han cambiado antes de la reconstrucción del núcleo, se usará el nombre utilizado anteriormente para este fichero. Por lo que si se copia la configuración anterior a un nuevo nombre, se podrá conservar la información para utilizar este fichero como punto de partida para una nueva configuración.
  • El segundo aspecto importante es conservar las imágenes del núcleo e initramfs que arrancan correctamente. La forma de realizar esto depende del contexto:
  1. Si el último núcleo que se construyó arranca correctamente, al lanzar genkernel se cambiará el nombre a la imagen este núcleo (y de igual forma al initramfs) a kernel-genkernel-ARCH-X.Y.Z-gentoo-rx.old y se creará un nuevo kernel-genkernel-ARCH-X.Y.Z-gentoo-rx. Esto implica que, en caso de que el nuevo núcleo no arranque, los usuarios siempre podrán arrancar con el antiguo.
  2. Si el último núcleo que se construyó no arranca y los ficheros fuente no han cambiado desde que el usuario construyó un nuevo núcleo, antes de lanzar genkernel, se deberá eliminar la nueva imagen del núcleo y quitar el sufijo .old del último núcleo que arrancara. Si no se hace esto y el nuevo núcleo construido no arranca en la segunda ocasión, el núcleo arrancable kernel-genkernel-ARCH-X.Y.Z-gentoo-rx.old será sustituido por el núcleo kernel-genkernel-ARCH-X.Y.Z-gentoo-rx que no arranca, por lo que usuario no podrá arrancar su sistema. Para initramfs se emplea el mismo razonamiento.
Nota
Since genkernel-4, it is recommended to create new, independent revisions each with its own kernel image, initramfs and installed modules in /lib/modules using genkernel --kernel-append-localversion=-my-new-revision all.

Utilizar el núcleo anterior mientras se cambian los ficheros fuente

Se puede utilizar la configuración anterior mediante la variable MENUCONFIG en /etc/genkernel.conf tal y como se indica a continuación:

ARCHIVO /etc/genkernel.confConfigurar make menuconfig
# ¿Lanzar 'make menuconfig' antes de compilar este núcleo?
MENUCONFIG="yes"
Nota
No es necesario lanzar make oldconfig cuando se utiliza genkernel incluso si se han cambiado los ficheros fuente de kernel-genkernel-ARCH-version-gentoo-rx a kernel-genkernel-ARCH-version-gentoo-r(x+1) o de kernel-genkernel-ARCH-version-gentoo a kernel-genkernel-ARCH-(version+1)-gentoo. Esto es debido a que make menuconfig intentará cargar la configuración anterior en el menú tanto como le sea posible. Se recomienda sin embargo revisar cada nueva sección y sus opciones.

Comprobar que initramfs incluye las herramientas necesarias antes de arrancar

Antes de arrancar el sistema, es recomendable comprobar que initramfs incluye las herramientas necesarias. Por ejemplo, si falta cryptsetup se producirá un error de pánico en el núcleo cuando se arranque con LUKS. Este artículo utiliza el siguiente procedimiento para comprobar que initramfs incluye cryptsetup:

Using lsinitrd

Since genkernel-4, created initramfs can be processed using the lsinitrd command from the sys-kernel/dracut package:

user $lsinitrd /boot/initramfs-5.3.14-gentoo-r1-x86_64-wifitest2.img
Image: /boot/initramfs-5.3.14-gentoo-r1-x86_64-wifitest2.img: 4,5M
========================================================================
Version: Genkernel 4.0.1 (2019年12月16日 00:48:10 UTC)
 
Arguments: --boot-font=none --keymap --compress-initramfs --no-microcode-initramfs --ramdisk-modules --busybox --no-btrfs --no-iscsi --no-multipath --no-dmraid --mdadm --lvm --no-unionfs --no-zfs --no-splash --no-strace --no-gpg --luks --no-firmware --firmware-dir=/lib/firmware --ssh --no-e2fsprogs --no-xfsprogs
 
dracut modules:
========================================================================
drwxr-xr-x 16 root root 0 Dec 16 01:49 .
drwxr-xr-x 2 root root 0 Dec 16 01:49 bin
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/ash -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/[ -> busybox
-rwxr-xr-x 1 root root 2351376 Dec 16 01:49 bin/busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/cat -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/cut -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/echo -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/mknod -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/mount -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/sh -> busybox
lrwxrwxrwx 1 root root 7 Dec 16 01:49 bin/uname -> busybox
drwxr-xr-x 2 root root 0 Dec 16 01:49 dev
drwxr-xr-x 8 root root 0 Dec 16 01:49 etc
-rw-r--r-- 1 root root 24 Dec 16 01:49 etc/build_date
-rw-r--r-- 1 root root 16 Dec 16 01:49 etc/build_id
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/dropbear
-rw------- 1 root root 140 Dec 16 01:49 etc/dropbear/dropbear_ecdsa_host_key
-rw------- 1 root root 806 Dec 16 01:49 etc/dropbear/dropbear_rsa_host_key
prw-r--r-- 1 root root 0 Dec 16 01:49 etc/dropbear/fifo_root
prw-r--r-- 1 root root 0 Dec 16 01:49 etc/dropbear/fifo_swap
-rw-r--r-- 1 root root 97 Dec 16 01:49 etc/fstab
-rw-r--r-- 1 root root 14 Dec 16 01:49 etc/group
-rw-r--r-- 1 root root 3742 Dec 16 01:49 etc/initrd.defaults
-rw-r--r-- 1 root root 69232 Dec 16 01:49 etc/initrd.scripts
-rw-r--r-- 1 root root 441 Dec 16 01:49 etc/ld.so.cache
-rw-r--r-- 1 root root 78 Dec 16 01:49 etc/ld.so.conf
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/ld.so.conf.d
-rw-r--r-- 1 root root 81 Dec 16 01:49 etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf
-rw-r--r-- 1 root root 2298 Dec 16 01:49 etc/localtime
drwxr-xr-x 3 root root 0 Dec 16 01:49 etc/lvm
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/lvm/cache
-rw-r--r-- 1 root root 95231 Dec 16 01:49 etc/lvm/lvm.conf
-rw-r--r-- 1 root root 2882 Dec 16 01:49 etc/mdadm.conf
drwxr-xr-x 3 root root 0 Dec 16 01:49 etc/mdev
-rw-r--r-- 1 root root 1172 Dec 16 01:49 etc/mdev.conf
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/mdev/helpers
-rwxr-xr-x 1 root root 666 Dec 16 01:49 etc/mdev/helpers/nvme
-rwxr-xr-x 1 root root 1295 Dec 16 01:49 etc/mdev/helpers/storage-device
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/modprobe.d
-rw-r--r-- 1 root root 1186 Dec 16 01:49 etc/modprobe.d/aliases.conf
-rw-r--r-- 1 root root 122 Dec 16 01:49 etc/modprobe.d/i386.conf
drwxr-xr-x 2 root root 0 Dec 16 01:49 etc/modules
-rw-r--r-- 1 root root 24 Dec 16 01:49 etc/modules/ataraid
-rw-r--r-- 1 root root 21 Dec 16 01:49 etc/modules/block
-rw-r--r-- 1 root root 180 Dec 16 01:49 etc/modules/crypto
-rw-r--r-- 1 root root 26 Dec 16 01:49 etc/modules/dmraid
-rw-r--r-- 1 root root 23 Dec 16 01:49 etc/modules/firewire
-rw-r--r-- 1 root root 123 Dec 16 01:49 etc/modules/fs
-rw-r--r-- 1 root root 86 Dec 16 01:49 etc/modules/hyperv
-rw-r--r-- 1 root root 40 Dec 16 01:49 etc/modules/iscsi
-rw-r--r-- 1 root root 437 Dec 16 01:49 etc/modules/lvm
-rw-r--r-- 1 root root 194 Dec 16 01:49 etc/modules/mdadm
-rw-r--r-- 1 root root 75 Dec 16 01:49 etc/modules/multipath
-rw-r--r-- 1 root root 214 Dec 16 01:49 etc/modules/net
-rw-r--r-- 1 root root 56 Dec 16 01:49 etc/modules/nvme
-rw-r--r-- 1 root root 519 Dec 16 01:49 etc/modules/pata
-rw-r--r-- 1 root root 83 Dec 16 01:49 etc/modules/pcmcia
-rw-r--r-- 1 root root 158 Dec 16 01:49 etc/modules/sata
-rw-r--r-- 1 root root 523 Dec 16 01:49 etc/modules/scsi
-rw-r--r-- 1 root root 350 Dec 16 01:49 etc/modules/usb
-rw-r--r-- 1 root root 133 Dec 16 01:49 etc/modules/virtio
-rw-r--r-- 1 root root 15 Dec 16 01:49 etc/modules/waitscan
-rw-r--r-- 1 root root 47 Dec 16 01:49 etc/passwd
-rw-r----- 1 root root 22 Dec 16 01:49 etc/shadow
-rw-r--r-- 1 root root 25 Dec 16 01:49 etc/shells
-rwxr-xr-x 1 root root 32331 Dec 16 01:49 init
drwxr-xr-x 2 root root 0 Dec 16 01:49 .initrd
drwxr-xr-x 6 root root 0 Dec 16 01:49 lib
lrwxrwxrwx 1 root root 3 Dec 16 01:49 lib32 -> lib
lrwxrwxrwx 1 root root 3 Dec 16 01:49 lib64 -> lib
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/console
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/dracut
-rw-r--r-- 1 root root 312 Dec 16 01:49 lib/dracut/build-parameter.txt
-rw-r--r-- 1 root root 42 Dec 16 01:49 lib/dracut/dracut-gk-version.info
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/keymaps
lrwxrwxrwx 1 root root 9 Dec 16 01:49 lib/keymaps/10.map -> croat.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/11.map -> cz.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/12.map -> de.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/13.map -> dk.map
lrwxrwxrwx 1 root root 10 Dec 16 01:49 lib/keymaps/14.map -> dvorak.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/15.map -> es.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/16.map -> et.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/17.map -> fi.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/18.map -> fr.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/19.map -> gr.map
lrwxrwxrwx 1 root root 10 Dec 16 01:49 lib/keymaps/1.map -> azerty.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/20.map -> hu.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/21.map -> il.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/22.map -> is.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/23.map -> it.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/24.map -> jp.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/25.map -> la.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/26.map -> lt.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/27.map -> mk.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/28.map -> nl.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/29.map -> no.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/2.map -> be.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/30.map -> pl.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/31.map -> pt.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/32.map -> ro.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/33.map -> ru.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/34.map -> se.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/35.map -> sf.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/36.map -> sg.map
lrwxrwxrwx 1 root root 8 Dec 16 01:49 lib/keymaps/37.map -> sk-y.map
lrwxrwxrwx 1 root root 8 Dec 16 01:49 lib/keymaps/38.map -> sk-z.map
lrwxrwxrwx 1 root root 11 Dec 16 01:49 lib/keymaps/39.map -> slovene.map
lrwxrwxrwx 1 root root 8 Dec 16 01:49 lib/keymaps/3.map -> bepo.map
lrwxrwxrwx 1 root root 7 Dec 16 01:49 lib/keymaps/40.map -> trf.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/41.map -> ua.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/42.map -> uk.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/43.map -> us.map
lrwxrwxrwx 1 root root 10 Dec 16 01:49 lib/keymaps/44.map -> wangbe.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/4.map -> bg.map
lrwxrwxrwx 1 root root 8 Dec 16 01:49 lib/keymaps/5.map -> br-a.map
lrwxrwxrwx 1 root root 8 Dec 16 01:49 lib/keymaps/6.map -> br-l.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/7.map -> by.map
lrwxrwxrwx 1 root root 6 Dec 16 01:49 lib/keymaps/8.map -> cf.map
lrwxrwxrwx 1 root root 11 Dec 16 01:49 lib/keymaps/9.map -> colemak.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/azerty.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/be.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/bepo.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/bg.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/br-a.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/br-l.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/by.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/cf.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/colemak.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/croat.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/cz.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/de.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/dk.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/dvorak.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/es.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/et.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/fi.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/fr.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/gr.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/hu.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/il.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/is.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/it.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/jp.map
-rw-r--r-- 1 root root 518 Dec 16 01:49 lib/keymaps/keymapList
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/la.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/lt.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/mk.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/nl.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/no.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/pl.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/pt.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/ro.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/ru.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/se.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/sf.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/sg.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/sk-y.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/sk-z.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/slovene.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/trf.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/ua.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/uk.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/us.map
-rw-r--r-- 1 root root 2823 Dec 16 01:49 lib/keymaps/wangbe.map
-rwxr-xr-x 1 root root 169376 Dec 16 01:49 lib/ld-linux-x86-64.so.2
-rwxr-xr-x 1 root root 1913648 Dec 16 01:49 lib/libc.so.6
-rwxr-xr-x 1 root root 26800 Dec 16 01:49 lib/libnss_dns.so
lrwxrwxrwx 1 root root 13 Dec 16 01:49 lib/libnss_dns.so.2 -> libnss_dns.so
-rwxr-xr-x 1 root root 51536 Dec 16 01:49 lib/libnss_files.so
lrwxrwxrwx 1 root root 15 Dec 16 01:49 lib/libnss_files.so.2 -> libnss_files.so
-rwxr-xr-x 1 root root 88736 Dec 16 01:49 lib/libresolv.so.2
drwxr-xr-x 3 root root 0 Dec 16 01:49 lib/modules
drwxr-xr-x 3 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2
drwxr-xr-x 5 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/crypto
-rw-r--r-- 1 root root 7152 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/crypto/algif_rng.ko
drwxr-xr-x 6 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers
drwxr-xr-x 3 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid/usbhid
-rw-r--r-- 1 root root 66448 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid/usbhid/usbhid.ko
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md
-rw-r--r-- 1 root root 19024 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-log.ko
-rw-r--r-- 1 root root 27256 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-mirror.ko
-rw-r--r-- 1 root root 49200 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-raid.ko
-rw-r--r-- 1 root root 16536 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-region-hash.ko
drwxr-xr-x 3 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel/e1000
-rw-r--r-- 1 root root 70480 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel/e1000/e1000.ko
drwxr-xr-x 6 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/common
-rw-r--r-- 1 root root 6584 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/common/usb-common.ko
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/core
-rw-r--r-- 1 root root 308944 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/core/usbcore.ko
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host
-rw-r--r-- 1 root root 60416 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ehci-hcd.ko
-rw-r--r-- 1 root root 10616 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ehci-pci.ko
-rw-r--r-- 1 root root 46072 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ohci-hcd.ko
-rw-r--r-- 1 root root 35896 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/uhci-hcd.ko
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/storage
-rw-r--r-- 1 root root 126512 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/storage/usb-storage.ko
drwxr-xr-x 3 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs
drwxr-xr-x 2 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat
-rw-r--r-- 1 root root 95664 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat/fat.ko
-rw-r--r-- 1 root root 16104 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat/msdos.ko
-rw-r--r-- 1 root root 32434 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.alias
-rw-r--r-- 1 root root 42356 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.alias.bin
-rw-r--r-- 1 root root 8132 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.builtin
-rw-r--r-- 1 root root 11529 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.builtin.bin
-rw-r--r-- 1 root root 15196 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.dep
-rw-r--r-- 1 root root 23748 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.dep.bin
-rw-r--r-- 1 root root 0 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.devname
-rw-r--r-- 1 root root 8320 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.order
-rw-r--r-- 1 root root 117 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.softdep
-rw-r--r-- 1 root root 24707 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.symbols
-rw-r--r-- 1 root root 29469 Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.symbols.bin
lrwxrwxrwx 1 root root 4 Dec 16 01:49 linuxrc -> init
drwxr-xr-x 2 root root 0 Dec 16 01:49 mnt
drwxr-xr-x 2 root root 0 Dec 16 01:49 proc
drwxr-xr-x 3 root root 0 Dec 16 01:49 root
drwx------ 2 root root 0 Dec 16 01:49 root/.ssh
-rw------- 1 root root 742 Dec 16 01:49 root/.ssh/authorized_keys
drwxr-xr-x 2 root root 0 Dec 16 01:49 run
-rw-r--r-- 1 root root 0 Dec 16 01:49 run/utmp
drwxr-xr-x 2 root root 0 Dec 16 01:49 sbin
-rwxr-xr-x 1 root root 1105720 Dec 16 01:49 sbin/blkid
-rwxr-xr-x 1 root root 2813384 Dec 16 01:49 sbin/cryptsetup
lrwxrwxrwx 1 root root 19 Dec 16 01:49 sbin/dmsetup -> ../usr/sbin/dmsetup
lrwxrwxrwx 1 root root 19 Dec 16 01:49 sbin/dmstats -> ../usr/sbin/dmstats
lrwxrwxrwx 1 root root 7 Dec 16 01:49 sbin/init -> ../init
lrwxrwxrwx 1 root root 15 Dec 16 01:49 sbin/lvm -> ../usr/sbin/lvm
-rwxr-xr-x 1 root root 1510360 Dec 16 01:49 sbin/mdadm
-rwxr-xr-x 1 root root 1267904 Dec 16 01:49 sbin/mdmon
drwxr-xr-x 2 root root 0 Dec 16 01:49 sys
drwxrwxrwt 2 root root 0 Dec 16 01:49 tmp
drwxr-xr-x 6 root root 0 Dec 16 01:49 usr
drwxr-xr-x 2 root root 0 Dec 16 01:49 usr/bin
lrwxrwxrwx 1 root root 13 Dec 16 01:49 usr/bin/dropbearconvert -> dropbearmulti
lrwxrwxrwx 1 root root 13 Dec 16 01:49 usr/bin/dropbearkey -> dropbearmulti
-rwxr-xr-x 1 root root 1365144 Dec 16 01:49 usr/bin/dropbearmulti
-rwxr-xr-x 1 root root 2881 Dec 16 01:49 usr/bin/login-remote.sh
lrwxrwxrwx 1 root root 13 Dec 16 01:49 usr/bin/scp -> dropbearmulti
drwxr-xr-x 2 root root 0 Dec 16 01:49 usr/lib
lrwxrwxrwx 1 root root 3 Dec 16 01:49 usr/lib32 -> lib
lrwxrwxrwx 1 root root 3 Dec 16 01:49 usr/lib64 -> lib
drwxr-xr-x 2 root root 0 Dec 16 01:49 usr/sbin
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_check -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_dump -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_metadata_size -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_repair -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_restore -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/cache_writeback -> pdata_tools
-rwxr-xr-x 1 root root 1262952 Dec 16 01:49 usr/sbin/dmsetup
lrwxrwxrwx 1 root root 7 Dec 16 01:49 usr/sbin/dmstats -> dmsetup
lrwxrwxrwx 1 root root 20 Dec 16 01:49 usr/sbin/dropbear -> ../bin/dropbearmulti
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/era_check -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/era_dump -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/era_invalidate -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/era_restore -> pdata_tools
-rwxr-xr-x 1 root root 2905416 Dec 16 01:49 usr/sbin/lvm
-rwxr-xr-x 1 root root 3061192 Dec 16 01:49 usr/sbin/pdata_tools
-rwxr-xr-x 1 root root 609 Dec 16 01:49 usr/sbin/resume-boot
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_check -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_delta -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_dump -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_ls -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_metadata_size -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_repair -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_restore -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_rmap -> pdata_tools
lrwxrwxrwx 1 root root 11 Dec 16 01:49 usr/sbin/thin_trim -> pdata_tools
-rwxr-xr-x 1 root root 3076 Dec 16 01:49 usr/sbin/unlock-luks
drwxr-xr-x 3 root root 0 Dec 16 01:49 usr/share
drwxr-xr-x 2 root root 0 Dec 16 01:49 usr/share/udhcpc
-rwxr-xr-x 1 root root 1098 Dec 16 01:49 usr/share/udhcpc/default.script
drwxr-xr-x 3 root root 0 Dec 16 01:49 var
drwxr-xr-x 2 root root 0 Dec 16 01:49 var/log
-rw-r--r-- 1 root root 0 Dec 16 01:49 var/log/lastlog
-rw-r--r-- 1 root root 0 Dec 16 01:49 var/log/wtmp
lrwxrwxrwx 1 root root 6 Dec 16 01:49 var/run -> ../run
========================================================================

The output above shows the e1000.ko file for an Intel NIC, the dropbear executable (usr/bin/dropbearmulti), and the cryptsetup (sbin/cryptsetup) executable have been embedded into the initramfs file.

Manual extraction

To extract a generated initramfs to inspect its content:

root # mkdir /tmp/initramfs
root # cd /tmp/initramfs
root # xzcat kernel-genkernel-x86_64-4.14.65-gentoo | cpio -idmv
root # ls -l sbin/cryptsetup
-rwxr-xr-x 1 root root 67568 28 d’oct 18:55 sbin/cryptsetup
Nota
Manual extraction will be difficult if CPU microcode updates have been embedded into the initramfs.

Microcode loading

For microcode (ucode) updates, kernel must support (early-)microcode loading and microcode updates must be present early at boot. See Microcode article for more details.

Microcode loading support in kernel

By default, genkernel will enable microcode loading support in kernel for both, AMD and Intel processors. This behavior can be controlled through MICROCODE option in /etc/genkernel.conf or by using the --microcode=(no|all|amd|intel) command-line parameter during invocation.

Embedding microcode updates into initramfs

To embed microcode (ucode) updates into initramfs, MICROCODE_INITRAMFS must be enabled in /etc/genkernel.conf or command-line parameter --microcode-initramfs must be passed at invocation. This will cause genkernel to prepend microcode(s) for selected processor (see --microcode option above) to initramfs in case sys-firmware/intel-microcode with the split-ucode USE flag for Intel processors and/or sys-kernel/linux-firmware for AMD processors is installed.

Nota
The technique of embedding microcode updates into the initramfs has been deprecated for modern systems in favor of using bootloaders (like sys-boot/grub ) which are capable of loading multiple initramfs files. When using GRUB, or another modern bootloader, it is recommended to install sys-firmware/intel-microcode for Intel and sys-kernel/linux-firmware for AMD processors, both require the initramfs USE flag to be enabled. Let the bootloader load /boot/amd-uc.img and/or /boot/intel-uc.img in addition to genkernel's initramfs. This will enable updating of the CPU microcode independently of kernel/initramfs updates.

Firmware loading

Specific firmware files can be added to genkernel's automatically generated initramfs when listed, with relative paths, in the variable FIRMWARE_FILES in /etc/genkernel.conf. When sys-kernel/genkernel is installed with USE="firmware" it will prefer firmware files from /lib/firmware.

ARCHIVO /etc/genkernel.confIncluding firmware in the initramfs
# Add firmware(s) to initramfs
FIRMWARE="yes"

# Specify directory to pull from
FIRMWARE_DIR="/lib/firmware"

# Specify a comma-separated list of firmware files or directories to include,
# relative to FIRMWARE_DIR. If empty or unset, the full contents of 
# FIRMWARE_DIR will be included (if FIRMWARE option above is set to YES).
FIRMWARE_FILES="<comma-separated list of firmware files here>"

In case sys-kernel/gentoo-sources is installed with USE="experimental" and the kernel is configured with CONFIG_GENTOO_PRINT_FIRMWARE_INFO=y, the following command gets a comma-separated list of all currently loaded firmware files for the use in the FIRMWARE_FILES variable from /etc/genkernel.conf as illustrated above (the output is just an example):

root #dmesg -t | grep '^Loading firmware*' | sed 's/^Loading\sfirmware:\s//' | echo $(cat) | tr ' ' ','
amdgpu/green_sardine_sdma.bin,amdgpu/green_sardine_asd.bin,amdgpu/green_sardine_ta.bin,amdgpu/green_sardine_pfp.bin,amdgpu/green_sardine_me.bin,amdgpu/green_sardine_ce.bin,amdgpu/green_sardine_rlc.bin,amdgpu/green_sardine_mec.bin,amdgpu/green_sardine_dmcub.bin,amdgpu/green_sardine_vcn.bin,regulatory.db,regulatory.db.p7s,rtw89/rtw8852a_fw.bin,rtl_bt/rtl8852au_fw.bin,rtl_bt/rtl8852au_config.bin,rtl_nic/rtl8168h-2.fw

It is also possible to incorporate the firmware into the kernel image directly, but be aware that CONFIG_EXTRA_FIRMWARE in the kernel configuration file .config (normally found in /usr/src/linux) requires a space-separated list (output example):

root #dmesg -t | grep '^Loading firmware*' | sed 's/^Loading\sfirmware:\s//' | echo $(cat)
amdgpu/green_sardine_sdma.bin amdgpu/green_sardine_asd.bin amdgpu/green_sardine_ta.bin amdgpu/green_sardine_pfp.bin amdgpu/green_sardine_me.bin amdgpu/green_sardine_ce.bin amdgpu/green_sardine_rlc.bin amdgpu/green_sardine_mec.bin amdgpu/green_sardine_dmcub.bin amdgpu/green_sardine_vcn.bin regulatory.db regulatory.db.p7s rtw89/rtw8852a_fw.bin rtl_bt/rtl8852au_fw.bin rtl_bt/rtl8852au_config.bin rtl_nic/rtl8168h-2.fw
Nota
Such a list will only be complete if the drivers successfully load all the required firmware(s): In case a driver requires more than one firmware file but fails loading the first one, only this will be listed and thereby other required firmware filenames will be missing. A recommended procedure to find all required firmware files is to compile the respective drivers as modules first, M in the kernel configuration, and to notthe modules in initramfs. The modules will be loaded after switching to the real / (root) directory, where all firmware files will be available from sys-kernel/linux-firmware (and others) under /lib/firmware. When a system boots successfully with this method, running the above command will gather a complete list of the required firmware files. The files can be included in the initramfs (or the kernel itself), allowing for the drivers to be compiled directly into the kernel, * in the kernel configuration, or to include the drivers as kernel modules in the initramfs as well. In both cases loading the modules will be earlier and it will be successful with the availability of the firmware files in the initramfs, which must be loaded alongside the kernel e.g. using GRUB.

Remote rescue shell

genkernel can embed the net-misc/dropbear SSH daemon into the initramfs which will allow fixing certain things on boot remotely when initramfs is at least able to load. The most common used feature will be remote unlock capability for LUKS-encrypted root or swap devices or ZFS volumes.

Pre-requirement for SSH daemon support in initramfs

A authorized_keys file must exist before genkernel will be invoked. By default, genkernel will look for /etc/dropbear/authorized_keys. Command-line argument --ssh-authorized-keys-file=/path/to/custom/authorized_keys or genkernel configuration option SSH_AUTHORIZED_KEYS_FILE can be used to alter default value.

Consejo
Create /etc/dropbear/authorized_keys as a symlink to /root/.ssh/authorized_keys for example to keep root access and remote rescue shell access in sync!

Adding SSH support to initramfs

To embed SSH daemon into genkernel's initramfs, run genkernel with --ssh command-line argument or set SSH="yes" in genkernel configuration file. Needless to mention that this feature will require working network at boot. The following example will just (re-)build initramfs with SSH daemon embedded:

root #genkernel --ssh initramfs
* Gentoo Linux Genkernel; Version 4.0.1
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: --ssh initramfs
 
* Working with Linux kernel 5.3.14-gentoo-r1-x86_64 for x86_64
* Using kernel config file '/etc/kernels/kernel-config-5.3.14-gentoo-r1-x86_64' ...
 
* initramfs: >> Initializing ...
* >> Appending devices cpio data ...
* >> Appending base_layout cpio data ...
* >> Appending auxilary cpio data ...
* >> Appending blkid cpio data ...
* >> Appending busybox cpio data ...
* >> Appending dropbear cpio data ...
=================================================================
This initramfs' sshd will use the following host key(s):
256 MD5:a5:13:09:90:5b:f6:a1:95:49:9f:87:d9:fa:e5:d8:02 (ECDSA)
256 SHA256:5dxNGEOwH9hvX4+sV4WtzRV/9m8/hrhgnNtTplZf5x8 (ECDSA)
2048 MD5:1d:e6:cc:ce:c8:96:a0:73:3e:4c:2a:56:ce:b9:10:26 (RSA)
2048 SHA256:V4WrMKhfVSxSeW3XIbW8dSaAmXiwN6jiMA/geNKLcqA (RSA)
=================================================================
* >> Appending modprobed cpio data ...
* >> Appending modules cpio data ...
* >> Appending linker cpio data ...
* >> Deduping cpio ...
* >> Pre-generating initramfs' /etc/ld.so.cache ...
* >> Compressing cpio data (.xz) ...
*
* You will find the initramfs in '/boot/initramfs-5.3.14-gentoo-r1-x86_64.img'.
 
* WARNING... WARNING... WARNING...
* Additional kernel parameters that *may* be required to boot properly:
* - Add "dosshd" to start SSH daemon in initramfs
 
* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
*
* Make sure you have the latest ~arch genkernel before reporting bugs.
Nota
By default, genkernel will generate own, dedicated SSH host keys for any missing supported key algorithm for embedded SSH daemon. This will allow to differentiate between real system's SSH daemon and initramfs' SSH daemon. To use host's SSH host keys instead or generate new keys at runtime on each boot use --ssh-host-keys command-line option and see genkernel's man page for more details.

Enabling SSH daemon on boot

Just adding SSH daemon to initramfs is not enough. Because exposing any network service could be a security risk, this feature must be enabled via the kernel command-line argument dosshd! See Configure Network for how to configure network in genkernel.

Remote unlock

There are two possibilities to unlock LUKS-encrypted root and/or swap volume: A manual way, through an SSH connection, run a command and will get prompted for passphrase(s) or an automatic way where user passes passphrase through SSH as command.

Nota
This will require a kernel/initramfs generated with --luks command-line argument and kernel must be booted with crypt_root (and/or crypt_swap) kernel command-line argument. ZFS user must generate kernel/initramfs with --zfs command-line argument and kernel must be booted with dozfs kernel command-line argument.
Manual unlock

Connect to the remote system through SSH and run the following commands:

user $ssh root@remote-system-running-genkernel-initramfs-with-dosshd
>> Welcome to Genkernel 4.0.1 (2019年12月16日 22:34:14 UTC) remote rescue shell!
>> ...running Linux kernel 5.3.14-gentoo-r1-x86_64
 
>> The lockfile '/tmp/remote-rescueshell.lock' was created.
>> In order to resume boot process, run 'resume-boot'.
>> Be aware that it will kill your connection which means
>> you will no longer be able to work in this shell.
>> To remote unlock LUKS-encrypted root device, run 'unlock-luks root'.
 
remote rescueshell ~ # unlock-luks root
>> Detected real_root as a md device. Setting up the device node ...
Enter passphrase for /dev/md126:
>> LUKS device /dev/md126 opened
remote rescueshell ~ # resume-boot
>> Resuming boot process ...
Nota
In this example, system was booted with just crypt_root= set in kernel command-line. In case system was booted with crypt_swap= there will be an additional prompt regarding how to unlock swap. ZFS user will get prompted to use unlock-zfs command instead.
Automatic unlock

It's basically the same like manual unlock just without the need to manually run resume-boot. In case user has both, encrypted root and swap volume, user must unlock swap volume first:

user $cat /path/to/secret.key/on/local/disk | ssh root@remote-system-running-genkernel-initramfs-with-dosshd post root
>> Detected real_root as a md device. Setting up the device node ...
>> LUKS device /dev/md126 opened
>> Resuming boot process ...
Nota
Automatic unlock is not available for ZFS users.

Arranque desde la red

Desde un CD de instalación

La utilidad genkernel puede construir el núcleo y las imágenes initrd que ofrecen soporte para arranque por red netbooting. Con un poco de suerte, los usuarios deberían poder arrancar desde la red con cualquier ordenador reciente dentro del entorno que ofrece el CD de instalación.

La magia está en el guión linuxrc de genkernel: Este intentará montar el CD de instalación en la red (netmount) usando NFS. A partir de aquí los guiones de inicio del CD de instalación pueden tomar el control como si el CD estuviera presente localmente.

Construir el núcleo e initramfs con soporte para arranque desde la red

Para habilitar el soporte de arranque por red, incluya las siguientes opciones mientras configura su núcleo:

Advertencia
El soporte para arranque por red con genkernel es experimental y puede presentar problemas.

En primer lugar, la imagen del núcleo debe incluir los controladores para las tarjetas de interfaz de red (NIC) del sistema. Normalmente, los controladores para estos dispositivos se compilarán como módulos. Sin embargo, es esencial (para el arranque por red) tener dichos controladores compilados directamente en la imagen del núcleo y no como módulos.

KERNEL Configurar un núcleo de la serie 3.x.x para ofrecer soporte a distintos controladores de NIC
Device Drivers --->
 Networking Support --->
 Ethernet (10 or 100Mbit) --->
 [*] Ethernet (10 or 100Mbit)
 <*> El controlador o controladores para cada tarjeta de red
Nota
Asegúrese de seleccionar <*> y no <M>.

En segundo lugar, se sugiere que se habilite la opción IP: kernel level autoconfiguration así como IP: DHCP support options. Esto evita una capa innecesaria de complejidad ya que la dirección IP y la ruta NFS al CD de instalación se pueden configurar en un servidor DHCP. Por supuesto, esto significa que la línea de órdenes del núcleo permanecerá constante para todas las máquinas, lo cual es muy importante para realizar etherbooting (arranque vía ethernet).

KERNEL Configurar un núcleo de la serie 3.x.x para ofrecer soporte a DHCP
Device Drivers --->
 Networking Support --->
 Networking options [*]
 TCP/IP networking--->
 [*] IP: kernel level autoconfiguration
 [*] IP: DHCP support

Estas opciones le indican al núcleo que envíe una petición DHCP en el momento del arranque.

Adicionalmente, debería activar SquashFS ya que la mayoría de los CD de instalación actuales de Gentoo así lo requieren. El soporte para SquashFS no se incluye en el árbol genérico de fuentes del núcleo. Para activar SquashFS, debe aplicar los parches necesarios para las fuentes genéricas del núcleo o instalar el paquete gentoo-sources.

KERNEL Configurar el núcleo para dar soporte a SquashFS
File systems--->
 Miscellaneous filesystems --->
 [*] SquashFS 2.X - Squashed file system support

Una vez completado el proceso de compilación, cree un tarball (tar.gz) que contenga los módulos del núcleo. Este paso es solo es necesario si su versión del núcleo no concuerda con la versión de la imagen del núcleo del CD de Instalación.

Para crear un archivo que contenga todos los módulos:

root #cd /
root #tar -cf /tmp/modules-X.Y.Z.tar.gz /lib/modules/X.Y.Z/

Dependiendo de su mecanismo de arranque por red necesitará seguir alguno de los siguientes pasos:

Para crear una imagen etherboot:

root #emerge --ask net-misc/mknbi
root #cd /boot
root #mkelf-linux -params="root=/dev/ram0 init=/linuxrc ip=dhcp" kernel... initrd... > etherboot.img

Para crear una imagen TFTP OpenBoot/SPARC64:

root #emerge --ask sys-apps/sparc-utils
root #cd /boot
root #elftoaout kernel... -o kernel.aout
root #piggyback64 kernel.aout System.map-... initrd-...
root #mv kernel.aout openboot.img

El fichero openboot.img es la imagen de inicio.

Para terminar, copie este núcleo al servidor TFTP. Los detalles de este paso dependen de la arquitectura y están fuera de la intención de esta guía. Por favor, consulte la documentación de la plataforma específica de su interés.

Configurar NFS

Para configurar un recurso compartido de NFS que contenga el CD de instalación, use el dispositivo loop para montar la imagen ISO y a continuación copie los contenidos del CD en el recurso NFS. Como característica extra, los guiones initrd de genkernel extraerán todos los archivos tar.gz ubicados en el directorio /nfs/livecd/add/. Todo lo que debe hacer aquí es copiar el fichero modules-X.Y.Z.tar.gz al directorio /nfs/livecd/add/.

Lo que sigue asume que /nfs/livecd es un recurso NFS compartido:

root #mount /tmp/gentoo-livecd.iso /mnt/cdrom -o loop
root #cp -p /mnt/cdrom /nfs/livecd
root #umount /mnt/cdrom

Ahora copie el fichero modules.tar.gz a /add:

root #mkdir /nfs/livecd/add
root #cp /tmp/modules-X.Y.Z.tar.gz /nfs/livecd/add

Configurar DHCP

Las imágenes del arranque por red (netboot) solicitarán a su servidor DHCP una dirección IP así como la opción root-path. Ambos se especificar en cada máquina usando un dirección MAC para identificarlas:

ARCHIVO /etc/dhcpd.confEjemplo de configuración cliente dhcpd.conf
# Aquí 192.168.1.2 es el servidor NFS y 192.168.1.10 será la dirección IP de la máquina que arranca por red
host netbootableMachine {
 hardware ethernet 11:22:33:44:55:66;
 fixed-address 192.168.1.10;
 option root-path "192.168.1.2:/nfs/livecd";
}

Instrucciones de arranque desde red

De nuevo indicaremos que el arranque por red depende en gran medida de la plataforma. La parte importante es especificar los parámetros ip=dhcp y init=/linuxrc en la línea de órdenes del núcleo pues esto activará la interfaz de red y le indicará a los guiones initrd que monten el CD de instalación a través de NFS. Se muestran a continuación algunos consejos que dependen de la plataforma:

Para etherboot, inserte el disco de etherboot en la unidad y reinicie. La línea de órdenes del núcleo se especificó cuando se construyó la imagen.

En Sparc64, pulse Stop+A en la línea de órdenes de arranque y a continuación teclee:

okboot net ip=dhcp init=/linuxrc

Para PXE, configure pxelinux (que es parte de syslinux) y a continuación cree un fichero pxelinux.cfg/default con las siguientes líneas:

ARCHIVO pxelinux.cfg/defaultEntrada por defecto
DEFAULT gentoo
TIMEOUT 40
PROMPT 1
LABEL gentoo
 KERNEL kernel-X.Y.Z
 APPEND initrd=initrd-X.Y.Z root=/dev/ram0 init=/linuxrc ip=dhcp

Iniciar un initramfs de genkernel

Introducción

Si instaló un initramfs con genkernel, eche un vistazo a las diversas opciones de inicio que puede (o debería) definir en la configuración de su gestor de arranque. Las más comunes se han incluido en esta guía.

Cargar LVM o software RAID

Si el sistema utiliza LVM o software RAID, tendrá que construir el initramfs utilizando las opciones --lvm y --mdadm. No olvide habilitar este soporte durante el inicio. Esto se puede hacer mediante las opciones dolvm y domdadm.

ARCHIVO /boot/grub/grub.confHabilitar el soporte para LVM o MDADM
# Ejemplo para for GRUB 1.x
title Gentoo Linux
root (hd0,0)
kernel /vmlinuz root=/dev/md3 dolvm domdadm
initrd /initramfs-genkernel-x86_64-3.4.3
Iniciar en modo de único usuario (single-user)

Si, por alguna razón, el inicio falla, debería poder rescatar su sistema iniciando en modo único usuario (single-user). Esto carga únicamente los servicios necesarios y a continuación ofrece un intérprete de órdenes de rescate (root).

ARCHIVO /boot/grub/grub.confIniciar en modo de único usuario (single-user)
# Ejemplo para GRUB 1.x
title Gentoo Linux
root (hd0,0)
kernel /vmlinuz root=/dev/md3 init_opts=S
initrd /initramfs-genkernel-x86_64-3.4.3

Cross-compile support

To build kernel and/or initramfs for a different platform as genkernel is being executed on, kernel/initramfs must be cross-compiled.

root #genkernel --mdadm --no-install --cross-compile=aarch64-linux-gnu all

The above command causes genkernel to create a kernel supporting MD raid and embed mdadm into initramfs (--mdadm), both kernel and initramfs will have to be manually installed (--no-install). The kernel and programs embedded into initramfs will run on arm64 (--cross-compile=aarch64-linux-gnu).

--cross-compile=<target triplet>
Target triple (i.e. aarch64-linux-gnu) to build for. Only needed when the system running genkernel has a different architecture like the system which should boot the created kernel/initramfs.
Consejo
The recommended way to create a cross-compile environment is using sys-devel/crossdev . See the how to create a cross-compile environment article for more details.

Initramfs kernel command-line parameters

Nota
The following parameter list is just an excerpt. Always check the version relevant man genkernel.
root=<...>
Specifies the device node of the root filesystem to mount. I.e. root=/dev/sda3, root=UUID=a1e5968c-bd1b-41ee-bf08-2d0ed376fa83.
cdroot
This attempts to load livecd.squashfs and is used for loading live media.
crypt_root=<...>
This specifies the device encrypted by LUKS, which contains the root filesystem to mount. Supports same syntax like root kernel command-line parameter from above.
Nota
Will require that at least initramfs was built with --luks option set.
crypt_swap=<...>
This specifies the swap device encrypted by LUKS. For more details please see crypt_root kernel command-line parameter from above.
root_trim=(yes|no)
Enables TRIM support for a LUKS-based root device.
Nota
Will require that at least initramfs was built with --luks option set and is only useful for flash-based volumes.
ip=<dhcp,addr/cidr>
Normally used to tell the kernel that it should start a network interface which can be specified using gk.net.iface kernel parameter. By default, dhcp will be used. A specific IP address can be set using addr/CIDR notation, i.e. 1.2.3.4/24.
gk.net.dhcp.retries=<...>
Sends up to 3 DHCP discovery requests by default.
gk.net.iface=<interface,macaddr>
Use the interface named eth0 by default. Use this kernel parameter to specify another interface.
A MAC address (00:00:00:00:00:00 format) can be specified instead of an interface name.
gk.net.gw=<...>
Optional gateway. If ip is set to dhcp, this kernel parameter will be ignored.
gk.net.routes=<...>
Optional additional routes. If ip is set to dhcp, this kernel parameter will be ignored.
gk.net.timeout.dad=<...>
Wait up to 10 seconds by default for IPv6's DAD to complete. At the moment, only wait for DAD while bringing down an interface to prevent a race condition.
gk.net.timeout.deconfiguration=<...>
Wait up to 10 seconds by default while bringing down an interface to prevent a race condition.
gk.net.timeout.dhcp=<...>
Wait up to 10 seconds by default for a DHCP server reply.
gk.net.timeout.interface=<...>
Wait up to 10 seconds by default for interface to show up.
gk.prompt.timeout=<...>
By default a prompt within genkernel initramfs like shown when set root could not be found will never timeout. Use this option to set a timeout.
Nota
When dosshd is used, gk.prompt.timeout will be set to 30 seconds when not set. This will allow remote user to provide answer through GK_PROMPT_FILE which is set to /tmp/current_prompt by default.
dosshd
Will bring up an interface and start a SSH daemon within initramfs allowing to remotely unlock encrypted devices or just for debugging purpose. See ip option for how to configure network.
Nota
Will require that initramfs was built at least with --ssh option set.
gk.sshd.port=<...>
By default, sshd will listen on port 22.
gk.sshd.wait=<...>
Wait X seconds after setting up sshd. Useful for login (and thus pause boot process) before booting real system.
dolvm
Activate LVM volumes on bootup.
Nota
Will require that initramfs was built at least with --lvm option set.
lvmraid=<...>
Specify RAID devices to set up before the activation of LVM volumes. Implies option dolvm from above.
domdadm (Deprecated in Genkernel 4.2.0, udev rules now control MD assembly)
Scan for RAID arrays on bootup.
Nota
Will require that initramfs was built at least with --mdadm option set.
dozfs[=cache,force]
Scan for bootable ZFS pools on bootup. Optionally use cachefile or force import if necessary or perform both actions.
Nota
Will require that initramfs was built at least with --zfs option set.
gk.log.disabled=<...>
By default, any shown message and external command calls will be logged to /tmp/init.log in initramfs. Disables logging.
gk.log.keep=<...>
When set to a boolean value, genkernel will preserve /tmp/init.log, see above, and copy file to /genkernel-boot.log on root device (see root or real_root kernel command-line parameter above). Customize to a file like /root/my-genkernel-boot.log to copy the log.
Nota
The default file /genkernel-boot.log on root was chosen because genkernel's initramfs will only mount root filesystem by default. To store the log file at /var/log/genkernel-boot.log, the mount point must be accessible (see /etc/initramfs.mounts).
gk.hw.load-all=<...>
By default, genkernel loads various module groups (nvme, sata, scsi, pata, usb...) until block device specified in root parameter (see above) becomes available. This boolean option can be used to force loading of all module groups regardless whether root device is already available when set to yes.

Resolución de problemas

Can genkernel be used for systemd-based systems?

Yes.

Genkernel? Dracut?

sys-kernel/dracut in comparison to sys-kernel/genkernel is just a generic tool for creating an initramfs. It does not create a kernel like genkernel does. I.e. while both, genkernel and dracut supports booting from LUKS-encrypted root volume, only genkernel will ensure that kernel will have all required options set. It's also worthwhile to mention that genkernel will compile most packages (LVM, cryptsetup, mdadm, sshd...) used in initramfs on its own whereas dracut will copy binaries from host system which can be a problem for some setups. Thus, genkernel supports kernel/initramfs creation for another system (cross-compile) unlike dracut or genkernel-next.

Can a separate kernel/initramfs be created for tests?

root #genkernel --kernel-config=/proc/config.gz --kernel-append-localversion=-test42 --menuconfig all

The above command causes genkernel to build a new kernel and initramfs (all) based on config from current running kernel (--kernel-config=/proc/config.gz), invoke menuconfig (--menuconfig) allowing user to adjust configuration and will append -test42 to kernel's LOCALVERSION variable (--kernel-append-localversion=-test42) which will affect naming of kernel image, modules dir and initramfs by default.

How can external modules (such as xtables-addons, nvidia-drivers...) be rebuilt for a new kernel?

By default, genkernel will call emerge @module-rebuild when building a kernel to ensure that out-of-tree modules installed through the package manager are still present in new/rebuilt kernel. This feature can be toggled via --[no-]module-rebuild command-line argument or MODULEREBUILD in /etc/genkernel.conf.

How can additional commands be run after building the kernel?

Genkernel provides a callback for that (before version 4, callback was used to rebuild external modules). See CMD_CALLBACK in /etc/genkernel.conf for more details.

How can ccache or distcc be used with genkernel?

Set up ccache or distcc the normal way like for sys-apps/portage . Set --kernel-cc command-line parameter or adjust KERNEL_CC in /etc/genkernel.conf for the desired tool to use. Do the same for UTILS_CC (--utils-cc) and UTILS_CXX (--utils-cxx).

ERROR: compile_kernel(): compile_generic() failed to compile the "bzImage" target!

Check /var/log/genkernel.log first. In most cases, a root cause will appear like:

ARCHIVO /var/log/genkernel.log
[...]
 AR drivers/usb/built-in.a
 AR drivers/built-in.a
 GEN .version
 CHK include/generated/compile.h
 AR built-in.a
 LD vmlinux.o
 MODPOST vmlinux.o
ld: .tmp_vmlinux1: final close failed: No space left on device
make: *** [Makefile:1032: vmlinux] Error 1
 
* ERROR: compile_kernel(): compile_generic() failed to compile the "bzImage" target!
* Please consult '/var/log/genkernel.log' for more information and any
* errors that were reported above.
*
* Report any genkernel bugs to bugs.gentoo.org and
* assign your bug to genkernel@gentoo.org. Please include
* as much information as you can in your bug report; attaching
* '/var/log/genkernel.log' so that your issue can be dealt with effectively.
*
* Please do *not* report kernel compilation failures as genkernel bugs!
*
 
* mount: >> Boot partition state on '/boot' was not changed; Skipping restore boot partition state ...
>>> Ended on: 2019年12月16日 02:30:19 (after 0 days 0 hours 07 minutes 49 seconds)
</pre>

In other words: The system has run out of disk space (No space left on device) during compilation.

To guard against problems like this set CHECK_FREE_DISK_SPACE_BOOTDIR=50 and CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR=4000 in /etc/genkernel.conf in which case genkernel would fail early with a message like

root #genkernel --kernel-config=/proc/config.gz all
* Gentoo Linux Genkernel; Version 4.0.1
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: --kernel-config=/proc/config.gz all
 
* Working with Linux kernel 4.19.89-gentoo-x86_64 for x86_64
* Using kernel config file '/proc/config.gz' ...
*
* Note: The version above is subject to change (depends on config and status of kernel sources).
* ERROR: 4000 MB free disk space is required in '/usr/src/linux' but only 1026 MB is available!
[...]

Is the order of kernel command-line arguments important?

No.

Required kernel option 'CONFIG_MICROCODE_INTEL' or 'CONFIG_MICROCODE_AMD' which genkernel tried to set is missing!

Kernel v6.6 permanently applied the kernel config parameters (see this commit). This was fixed in version 4.3.10 of sys-kernel/genkernel .

Help! Something isn't working!

To report a problem, please always provide /var/log/genkernel.log (sometimes it maybe necessary to compress that file before sharing or attaching to bugs) which will help developers a lot. Even if the command is run with --loglevel=1 (default), the logfile will always contain complete output (no need to re-run with logging turned on) which will help developers to understand, reproduce and maybe fix a bug.

Véase también


Authorship information
This page is based on a document formerly found on gentoo.org.
The following people contributed to the original document: Tim Yamin, Jimi Ayodele, Thomas Seiler, Joshua Saddler (nightmorph), Sebastian Pipping (sping) , José Fournier (jaaf)

Editors: please do not add yourself here. Contributions are recorded on each article's associated history page, this list is only present to preserve authorship information, as wiki history does not allow for any external attribution.