Genkernel/fr

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:

Usage
La forme générale de l'invocation de genkernel est la suivante :

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


 * ramdisk</tt>
 * Only builds the initramfs/ramdisk image.

Starting off
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.

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

File management
Quand il utilise genkernel, l'utilisateur doit être conscient de quelques aspects concernant la gestion des fichiers de configuration et des fichiers image du noyau, ainsi que de la façon dont les sources du noyau sont manipulées par le système.

Source files
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.

Le dossier  pourrait ressembler à ceci :

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 (exclusively) use the sources pointed by the symlink.

Kernel configuration file
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   might be substituted with the system's architecture,   might be substituted with the version of the sources used, and   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.

Sauvegarder la configuration compilée
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.

Installing the kernel and initramfs into the directory
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.


 * Le second paramètre indique à genkernel de sauvegarder la configuration du noyau compilé dans.


 * 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:

Configurer le chargeur de démarrage
Les liens symboliques présentées plus haut peuvent être utilisés pour configurer le chargeur de démarrage, de telle manière que même si le nouveau noyau n'est pas amorçable, l'utilisateur puisse toujours redémarrer sur l'ancien.

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.

Voici à quoi le fichier  pourrait ressembler.

Preserving the working files
L'application genkernel sauvegarde automatiquement les changements des fichiers. Si les changements précédents doivent être sauvegardés, les actions suivantes sont à envisager.


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

Utiliser la configuration précédente du noyau tout en changeant de sources
The previous configuration can be used through the  option in  as follows:

From an installation CD
L'outil genkernel peut fabriquer des images de noyaux et de disque virtuel initial (initrd) qui permettent de démarrer sur le réseau (netboot). Avec un peu de chance, vous devriez pouvoir faire démarrer n'importe quel ordinateur récent par le réseau sur l'environnement fourni par le CD-ROM d'installation de Gentoo.

La magie de la chose réside dans le script linuxrc de genkernel : il va essayer de monter le CD-ROM d'installation par NFS via le réseau. Partant de là, les scripts d'initialisation du CD-ROM d'installation seront utilisés comme si le CD était présent en local.

Building the kernel and initramfs with netboot support
Pour activer le support du démarrage par le réseau, activez les options suivantes lors de la configuration du noyau :

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.

Assurez-vous de choisir &lt;*&gt;</tt> et non pas &lt;M&gt;</tt>.

Ensuite, nous vous suggérons d'activer IP: kernel level autoconfiguration et IP: DHCP support. Cela évitera une couche supplémentaire de complexité si l'adresse IP et le chemin NFS du CD-ROM d'installation peuvent être spécifiés par un serveur DHCP. Bien sûr, cela signifie que la ligne de commande d'appel du noyau sera la même pour toutes les machines.

Ces options indiquent au noyau d'envoyer une requête DHCP au démarrage.

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.

Une fois que le processus de compilation est terminé, créez une archive compressée (.tar.gz) qui contient les modules du noyau. Cette étape n'est nécessaire que si la version de votre noyau ne correspond pas à la version de l'image située sur le CD-ROM d'installation.

Pour créer une archive contenant tous les modules :

Selon votre méthode de démarrage par le réseau, vous devrez exécuter certaines des étapes suivantes :

Créer une image etherboot.

Pour créer une image TFTP OpenBoot / SPARC64.

Le fichier est l'image à démarrer.

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.

Configuration du NFS
Pour mettre en place un partage NFS qui contient le CD-ROM d'installation, utilisez un périphérique de bouclage (loop device) pour y monter l'image ISO et copiez le contenu du CD dans le partage NFS. En bonus, le script initrd de genkernel désarchivera tous les fichiers .tar.gz situés dans le répertoire. Tout ce qu'il vous reste à faire est de copier votre archive  dans le répertoire.

En supposant que  soit un partage NFS.

Copiez dans

Configuration du 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
Le démarrage par le réseau est encore une fois très spécifique à la plate-forme utilisée. Ce qui est important, c'est de spécifier les paramètres   et   sur la ligne de commande du noyau. Cela activera la carte réseau et montera le CD-ROM d'installation via NFS. Voici quelques astuces pour certaines plates-formes :

Pous etherboot, insérer le disque etherboot dans le lecteur et redémarrez. La ligne de commande du noyau a été spécifiée lors de la construction de l'image. Avec Sparc64, pressez - à l'invite de démarrage et entrez :

For PXE, Configurez pxelinux (qui fait partie de syslinux), puis créez un fichier qui contient ces lignes:

Introduction
Si vous avez installé un disque virtuel initial (initramfs) avec genkernel, vous devriez assurément regarder les options diverses et variées de boot que vous pouvez (ou devez) définir dans la configuration de votre chargeur de démarrage. Les plus courantes sont citées ici pour référence.

Chargement de LVM ou de 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.

Booting in single-user mode
Si, pour une raison ou une autre, le démarrage échoue, récupérer le système en démarrant le mode utilisateur unique reste possible. Ceci ne chargera que les services réellement nécessaires et offrira à l'utilisateur un shell de récuppration root.

compile failed: Kernel not found
This failure can be experienced when attempting to compile a kernel for one architecture with a kernel file that has a target of a different architecture than the target. This could be as simple as a machine running an kernel attempting to compile for a  target.

This can be experienced when booting from a x86_64 livecd on a system that is capable of operating in 64-bits, however the target to be installed or repaired is 32-bits. After the compilation process begins, genkernel</tt> will attempt to automatically detect the architecture for the target based on the currently running kernel. If the currently running kernel is 64-bit, then, unless it is told otherwise, genkernel</tt> will presume it should be looking for a 64-bit kernel.

Suppose then that the kernel's file has x64 disabled. The make</tt> command will execute and the resulting kernel binary will be placed in the associated directory. When <tt>genkernel</tt> goes to install (move and rename) the kernel it cannot find the kernel because it expected a 64-bit kernel.

The solution to this failure is to set <tt>genkernel</tt>'s  option to, in this case, the  architecture. The final command could look like this:

To override the architecture choice permanently, modify the  variable in the  file.