Genkernel/es

genkernel is a tool used to automate the build process of the kernel and initramfs. Some of the general features include:


 * Configuring the kernel sources;
 * Building the compressed kernel and copying it to
 * Creating an initramfs and copying it to
 * Creating symlinks in
 * Adding custom content to the initramfs such as encryption related files, boot splash images, extra modules, and more;
 * Compressing the initramfs;
 * Configuring the bootloader.

Emerge
Initiate the installation of genkernel:

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

Opciones
The actual behavior of genkernel depends on a large variety of options, the majority of which can be set/unset in the file or passed via the genkernel command on each invocation. Options passed over the command line take precedence over options defined in. The configuration file is very well documented, however some of the most commonly used options will be explored in this article. The goal is for the reader to be familiar with common genkernel invocations. For a more complete set of explanations refer to the comments in itself or to the output of the man genkernel command.

Options acting on user interactivity
The configuration options listed below help the user decide how to interact with the configuration process. Users can even choose whether or not the configuration file created in the process should be saved. The following are considered primary configuration options:

Options acting on the resulting system
The configuration options listed here defines which features will or will not be enabled in the resulting kernel and initrd.

Options acting on the choice of the tools used for building
The following options are supported by genkernel, and are passed to the relevant applications while the kernel is being assembled. These options affect the compiling tools used for the kernel compilation process, albeit at a much lower level.

Options acting on the compilation process
The following options usually take effect during the actual compilation:

Debugging options
The use of debugging options during the kernel compilation process controls the amount of information reported, as well as the presentation of said data.

Actions
The action passed on the command line with the genkernel [options …] action tells genkernel what action to perform. The following actions are supported:


 * 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</tt>
 * Only builds the initramfs/ramdisk image.

genkernel first invocation
Although there are several ways to run genkernel, the least-intrusive approach recommended for most users is provided by genkernel all</tt>. Here, a generic configuration which works well for most systems is used. As was mentioned earlier, this approach is not without drawbacks; most of the modules created are useless to the average user and may increase compile time. Below is an illustration of a more efficient approach, achieved by passing certain options to genkernel as root:

The above operation causes genkernel to create a framebuffer splash-enabled kernel that will have to be manually installed. While preparing the kernel source tree, genkernel will refrain from cleaning out any preexisting object files present in the source tree. A menu-driven kernel configuration utility will be displayed that allows the user to select which modules will be built for the system.

Replacing  with the   option allows genkernel to automatically install the new kernel in the  directory, and will create symlinks if   is specified. Using the  option allows genkernel to mount the  partition automatically, if necessary.

Using genkernel to change the kernel
The first thing that should be done is to allow the triggering of make menuconfig</tt> in the file:

File management by genkernel
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.

Source files used by genkernel
After an emerge -u gentoo-sources</tt>, whenever new sources are available, a new kernel source directory is created under to host them. Normally, the active kernel sources directory is pointed to by the symlink.

El directorio debería un aspecto similar a este:

The symlink can be changed in different ways.


 * If the  USE is set the  symlink is automatically updated to point to the newly emerged sources.


 * If the  USE is not set, the user can change the destination of the symlink using the eselect kernel list</tt> followed by the eselect kernel set</tt> command.

genkernel will always use the sources pointed by the symlink.

Kernel configuration file used by genkernel
If a kernel compilation has already been run with the active kernel sources, there might be a file inside the directory that contains the kernel configuration that has been applied while creating the last bzimage of the kernel. This file is named, for example where x86_64 might be substituted with the system's architecture, 3.7.9 might be substituted with the version of the sources used and r1 with the release of the sources.

It is this file that is used as a starting configuration when running  genkernel --menuconfig all</tt>.

If it is the first time that genkernel is run with the new kernel sources, or if the previous result has not been saved, this file is substituted with a default configuration file that resides at where x86_64 is substituted with the actual architecture.

Guardar la configuración compilada
If the  genkernel option is activated, either from the command line or inside, the compiled kernel configuration is saved (with the name given above) into the  directory. At the same time, the configuration is saved in the file in  directory but this file is not reused on the next genkernel all</tt> run.

Instalar el núcleo y el initramfs en el directorio /boot
Specifying the  option when invoking genkernel, will ask genkernel to install the kernel image and the initramfs into the  directory. In order to run  a convenient manner, set the following in the  file:


 * The first parameter speaks for itself.


 * El segundo parámetro le indica a genkernel que guarde la configuración del núcleo que se ha compilado en.


 * The last two options tell genkernel to automatically update the grub configuration. In practice, the following happens:
 * If a previous kernel image with the same name already exist, it is renamed by appending to its name. A symlink  is automatically created that points to it.
 * The new kernel takes the place of any kernel with the same name into . If it is the first time a kernel is compiled, a symlink kernel is automatically created that points to the new kernel.

After running genkernel --menuconfig all</tt>, the directory might look like this:

Configurar el gestor de arranque
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.

To allow the kernel and intird provided by genkernel to run correctly, provide a minimum information in bootloader's configuration file :
 * Add  to the kernel parameters passed to the kernel image, where  points to the root partition.
 * If splash is used, add a suitable mode line such as  to the parameters passed to the kernel and also add   or   depending on the verboseness required through the boot process.
 * Add the initrd information as required by the bootloader. Consult the Bootloader Configuration Chapter of the Gentoo Handbook for details on how to make the bootloader initrd-aware.

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

Preserving the working files
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.


 * The first file to preserve is the kernel configuration file in If the source has not changed prior to the recompilation of the kernel, the previously used name for this file will be used. So copying the previous configuration file under a different name helps in preserving the information while keeping the file available as a starting point for a new configuration.


 * The second important thing is to preserve the already bootable kernel and initramfs images. The way to accomplish this depends on the context:
 * If the last kernel compiled is bootable, running genkernel will rename this kernel (and similarly initramfs) image to and create a new . This mean that even if the new kernel is not bootable, users will always be able to boot the old one.
 * If the last kernel compiled is not bootable and sources haven't changed since the user compiled a bootable one, prior to running genkernel, first delete the new kernel image and remove the .old</tt> suffix from the last bootable one. Without this, if the newly compiled kernel is not bootable for the second time, the bootable will be kicked out by the renaming of the non bootable, giving the user an unbootable system. Use the same reasoning for initramfs.

Utilizar el núcleo anterior mientras se cambian los ficheros fuente
The previous configuration can be used through the make menuconfig</tt> option in as follows:

From an installation CD
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.

Building the kernel and initramfs with netboot support
Para habilitar el soporte de arranque por red, incluya las siguientes opciones mientras configura su núcleo:

First, the kernel image must include the drivers for the system's Network Interface Cards (NIC). Normally, drivers for such devices will be compiled as modules. However, it is essential (for netbooting) that such drivers are compiled directly into the kernel image and not as modules.

Asegúrese de seleccionar &lt;*&gt;</tt> y no &lt;M&gt;</tt>.

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).

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

Additionally, enable SquashFS because most modern Gentoo Installation CDs require it. Support for SquashFS is not included with the generic kernel source tree. To enable SquashFS, apply the necessary patches to the generic kernel source or install gentoo-sources.

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:

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

Para crear una imagen etherboot:

Para crear una imagen TFTP OpenBoot/SPARC64

El fichero es la imagen de inicio.

Finally, copy this kernel to the TFTP server. The details are architecture-dependent and are beyond the scope of this guide. Please refer to the documentation for the specific platform of interest.

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. Todo lo que debe hacer aquí es copiar el fichero al directorio.

Lo que sigue asume que es un recurso NFS compartido:

Ahora copie el fichero a :

Configurar DHCP
The netboot images will ask the DHCP server on the network for an IP as well as a  option. Both can be specified per host using a MAC address to identify machines:

Netbooting instructions
De nuevo indicaremos que el arranque por red depende en gran medida de la plataforma. La parte importante es especificar los parámetros  y  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 - en la línea de órdenes de arranque y teclee:

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

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
If the system uses LVM or software-RAID, the initramfs has to be built using the  and   options. Do not forget to enable support during boot as well. This can be done using the dolvm and domdadm options.

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).

Véase también

 * Configuración manual del núcleo - Para cuando sea necesario hacer las cosas de forma manual.
 * Dracut - Otro constructor de initramfs disponible en Gentoo.

Recursos externos

 * Repositorio del código fuente de genkernel (GitWeb).