Genkernel/fr

genkernel est utilisé pour automatiser le processus de compilation du   noyau et du système de fichiers virtuel de démarrage (initramfs). Parmi les fonctionnalités citons :
 * la configuration des sources du noyau
 * la compilation de l'image compressée du noyau  et sa copie dans
 * la création d'un système de fichiers virtuel du démarrage (initramfs) et sa copie dans
 * la création des liens symboliques dans
 * l'ajout d'un contenu personnalisé au système de fichiers virtuel de démarrage (initramfs) comme par exemple les fichiers relatifs au chiffrage, les écrans d'attente, les modules supplémentaires et plus encore.
 * la compression de l'initramfs
 * la configuration du chargeur de démarrage

Installation
Pour installer le paquet, commencez par sélectionner les options de la variable USE appropriées.

Ensuite, vous pouvez procéder à l'installation du paquet genkernel.

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

Options
Le comportement réel de genkernel dépend d'une grande variété d'options, dont la majorité peut être activée/désactivée dans le fichier ou passer avec la commande. Les options passées en ligne de commande prévalent sur celles définies dans. Ce fichier est très bien documenté. Nous examinerons néanmoins ici quelques unes des options les plus communes. Pour une information plus complète, reportez-vous aux commentaires du fichier ou à la sortie de la commande.

Options agissant sur l'interactivité de l'utilisateur
Les options de configuration listées ci-dessous permettent de décider comment interagir avec le processus de configuration. L'utilisateur peut même décider si le fichier de configuration sera ou pas sauvegardé. Les options suivantes sont les options de configuration de premier ordre :


 * --[no-]menuconfig
 * Active [ or désactive] la commande   (qui invoque un menu interactif de configuration) avant de compiler le noyau.


 * --gconfig
 * fournit un outil de configuration du noyau qui dépend des bibliothèques GTK+. L'avantage de cette option est que la majorité des utilisateurs trouvent cette interface plus claire et facile à utiliser pour configurer le noyau, puisqu'elle utilise le système X-Window. Son inconvénient est que vous devez avoir X-Window pour l'utiliser, cela ne marchera pas dans une console en ligne de commande.


 * --xconfig
 * fournit un outil de configuration du noyau qui dépend des bibliothèques Qt. L'avantage de cette option est que la majorité des utilisateurs trouvent cette interface plus claire et facile à utiliser pour configurer le noyau, puisqu'elle utilise le système X-Window. Son inconvénient est que vous devez avoir X-Window pour l'utiliser, cela ne marchera pas dans une console en ligne de commande.


 * --[no-]save-config
 * sauvegarde [ou ne sauvegarde pas] la configuration du noyau dans un fichier situé dans le répertoire pour une future utilisation.


 * --kernname=&lt;NickName&gt;: vous permet de nommer le noyau et le disque virtuel initial (initrd).qui seront copiés dans, de sorte que les noms de fichier produits soient kernel-Nom-version et initramfs-Nom-version.

Options agissant sur le système résultant
Les options définies ici définissent quelles fonctionnalités, seront, ou ne seront pas, incluses dans le noyau et le système de fichiers virtuel de démarrage résultants.


 * --[no-]splash
 * ajoute [ou n'ajoute pas] la prise en charge de l'écran d'attente en tampon de trame (splash framebuffer) au sytème de fichiers virtuel de démarrage (initrd) que construit genkernel. Pour écraser le thème par défaut utilisé par fbsplash, utilisez --splash=&lt;MonThème&gt; (où &lt;MonThème&gt; est le nom de l'un des répertoires situés dans ).


 * --splash-res=&lt;PreferredResolution&gt;</tt>
 * cette option vous permet de sélectionner les résolutions prise en charge par l'initrd au démarrage. Elle est utile pour deux raisons : d'abord, vous pouvez choisir quelles résolutions sont prises en charge spécifiquement par votre système, ensuite, vous réduisez la quantité d'espace occupée par l'initrd puisque ce dernier n'a plus à s'occuper des résolutions que vous n'utiliserez pas. Cependant, vous pouvez ignorer cette option si vous compilez un noyau pour un CD d'installation, ce qui permettra à bootsplash de prendre en charge toutes les résolutions.


 * --do-keymap-auto</tt>
 * force la sélection de l'arrangement de clavier lors du démarrage.


 * --lvm</tt>
 * inclut la prise en charge des volumes gérés par LVM2 grâce à des binaires statiques, s'ils sont disponibles. Les binaires (statiques) LVM2 en question sont compilés lorqu'ils manquent. Assurez-vous d'avoir installé le paquet lvm2 sur votre système avec emerge lvm2 avant d'activer cette option et d'avoir lu l'article LVM sur ce wiki.


 * --dmraid</tt>
 * inclut la prise en charge de DMRAID, l'outil qui crée des volumes RAID logiciels en utilisant le sous-système device-mapper du noyau. DMRAID découvre, active, désactive et affiche les propriétés des volumes RAID (ATARAID par exemple) ainsi que celles des partition DOS incluses.


 * --luks</tt>
 * inclut le support de Linux Unified Key Setup (LUKS). Cela vous permettra d'utiliser un périphérique chiffré par LUKS pour placer votre système de fichiers racine (/). Spécifiez alors au chargeur de démarrage le nom de ce périphérique via la variable   (  doit être le nom du périphérique une fois déchiffré par LUKS).


 * --disklabel</tt>
 * ajoute la prise en charge de disk label (étiquette de disque) and UUID (Identifiant Unique Universel) à votre disque virtuel initial (initrd).


 * --iscsi</tt>
 * ajoute la prise en charge de iSCSI à votre disque virtuel initial (initrd).


 * --multipath</tt>
 * ajoute la prise en charge de Multipath à votre disque virtuel initial (initrd).


 * --linuxrc=/path/to/your/linuxrc</tt>
 * spécifie un script linuxrc créé par l'utilisateur qui sera appelé lors de la phase de démarrage du noyau, avant le démarrage du système. (Un script linuxrc par défaut devrait se trouver dans .) Ce script vous permet d'amorcer sur un petit noyau modulaire et de charger les pilotes requis (sous forme de modules) par le système avant le démarrage.


 * --cachedir=/path/to/alt/dir</tt>
 * remplace le chemin par défaut du cache utilisé pendant la compilation.


 * --tempdir=/path/to/new/tempdir</tt>
 * spécifie le chemin du répertoire temporaire utilisé par genkernel lors de la compilation du noyau.


 * --unionfs</tt>
 * inclut la prise en charge de Unification File System dans votre disque virtuel initial (initrd).


 * --mountboot</tt>
 * détecte si le répertoire   a besoin d'être monté en lisant le  et en y prenant les instructions sur la manière de le monter.

Options acting on 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.


 * --kernel-cc=&lt;someCompiler&gt;</tt>
 * Specifies the compiler employed during the kernel compilation process.


 * --kernel-ld=&lt;someLinker&gt;</tt>
 * Specifies the linker employed during the kernel compilation process.


 * --kernel-as=&lt;someAssembler&gt;</tt>
 * Specifies the assembler employed during the kernel compilation process.


 * <tt>--kernel-make=&lt;someMake&gt;</tt>
 * Specifies an alternative to the GNU make utility employed during the kernel compilation process.


 * <tt>--utils-cc=&lt;someCompiler&gt;</tt>
 * Specifies the compiler employed during the compilation of support utilities.


 * <tt>--utils-ld=&lt;someLinker&gt;</tt>
 * Specifies the linker employed during the compilation of support utilities.


 * <tt>--utils-as=&lt;someAssembler&gt;</tt>
 * Specifies the assembler employed during the compilation of support utilities.


 * <tt>--utils-make=&lt;someMake&gt;</tt>
 * Specifies an alternative to the GNU make utility employed during the compilation of support utilities.


 * <tt>--makeopts=-jX</tt>
 * Specifies the number of concurrent threads that the make utility can implement while the kernel (and utilities) are being compiled. The variable  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   or  ; a system with two cores most likely uses the   or   options, and so on. (A system with one processor that supports Hyper-Threading™ (HT) Technology can be assumed to have 2 cores, provided Symmetric Multi-Processing (SMP) support is enabled in the kernel.)

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


 * <tt>--kerneldir=/path/to/sources/</tt>
 * Specifies an alternative kernel source location, rather than the default location.


 * <tt>--kernel-config=/path/to/config-file</tt>
 * Specifies what alternative kernel configuration will be used, rather than the default file.


 * <tt>--module-prefix=/path/to/prefix-directory/</tt>
 * Specifies a prefix to the directory where kernel modules will be installed (default path is the directory.)


 * <tt>--no-clean</tt>
 * Activates [or deactivates] the  command before compiling your kernel. The   command removes all object files and dependencies from the kernel's source tree.


 * <tt>--no-mrproper</tt>
 * Activates [or deactivates] the  command before kernel compilation. Like the   command,   removes all object files and dependencies from the kernel's source tree. However, any previous configuration files (in  or ) will also be purged from the kernel's source tree.


 * <tt>--oldconfig</tt>
 * Issues the  command, which attempts to collect configuration information for the system's architecture from a generic script in . This is a non-interactive process; no user input is entertained. Also, if <tt>--oldconfig</tt> is used in conjunction with <tt>--clean</tt>, the latter option is negated, resulting in the activation of the <tt>--no-clean</tt> option.


 * <tt>--callback="echo hello"</tt>
 * Calls the specified arguments (, in this case) after the kernel and the relevant modules have been built, but before building the initrd image. This may be useful if you want to install external modules in the initrd image by emerging the relevant item(s) with the callback feature, and then redefining a genkernel module group.


 * <tt>--[no-]install</tt>
 * Activates [or deactivates] the make install command, which installs your new kernel image, configuration file, initrd image and system map onto your mounted boot partition. Any compiled modules will be installed as well.


 * <tt>--no-ramdisk-modules</tt>
 * Refrains from copying any modules to the genkernel-created initrd image. This option is an exception to the rule about the <tt>no-</tt> prefix; omission of this prefix creates an invalid genkernel option.


 * <tt>--all-ramdisk-modules</tt>
 * Copies all available modules to the genkernel-created initrd image.


 * <tt>--genzimage</tt>
 * Creates the initrd image, prior to the kernel image. (This hack currently applies only to PPC Pegasos systems.)

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.


 * <tt>--loglevel=&lt;verblevel&gt;</tt>
 * Controls the level of verbosity for information provided by genkernel. The variable  is an integer between 0 and 5. The level '0' represents minimal output, while '5' provides as much information as possible about genkernel's activities during the kernel compilation process.


 * <tt>--logfile=/path/to/outputfile</tt>
 * Ignores the value set by the <tt>--loglevel</tt> argument, and sends all debugging data produced by genkernel to the specified output file, which is located at by default.


 * <tt>--no-color</tt>
 * Activates (or deactivates) colored output of debugging information (reported by genkernel) using escape sequences.

Action
The action passed on the command line with the  command, tells    what to do - the following actions are supported:


 * Builds all stages — the initrd, kernel image and modules.
 * Builds all stages — the initrd, kernel image and modules.


 * Only builds the kernel image
 * Only builds the kernel image


 * Only builds the kernel image and modules
 * Only builds the kernel image and modules


 * Only builds the initramfs/ramdisk image
 * Only builds the initramfs/ramdisk image


 * Only builds the initramfs/ramdisk image
 * 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. 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 (<tt>--splash</tt>) that will have to be manually installed (<tt>--no-install</tt>). While preparing the kernel source tree, genkernel will refrain from cleaning out any preexisting object files present in the source tree (<tt>--no-clean</tt>). A menu-driven kernel configuration utility will be displayed that allows the user to select which modules will be built for the system (<tt>--menuconfig</tt>).

Replacing <tt>--no-install</tt> with the <tt>--install</tt> option allows genkernel to automatically install the new kernel in the directory, and will create symlinks for you if <tt>--symlink</tt> is specified. Using the <tt>--mountboot</tt> option allows genkernel to mount the partition automatically, if necessary.

Using Genkernel to change your kernel
The first thing that should be done is to allow the triggering of  in the  file:

File Management by genkernel
While using genkernel, the user has to be aware of some aspects relating to kernel configuration and kernel image files management and the way the kernel sources are handled by the system.

Source Files used by genkernel
After an, 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.

The directory might look like this:

The symlink can be changed in different ways.


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


 * If the previous USE flag is not set, the user can change the destination of the symlink using the   command.

Whatever it is,  always uses the sources pointed by this 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 your architecture,  3.7.9 might be substituted with the version of the sources you are using and r1 with the release of the sources..

It is this file that is used as a starting configuration when running   }}.

If it is the first time that  is run, 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.

Saving the compiled configuration
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   run.

Installing the kernel and initramfs into the /boot directory
The  action specified when invoking genkernel, ask   to install the kernel image and the initramfs into the  directory. In order to do it in a convenient manner, set the following in the  file:


 * The first parameter speaks by itself.


 * The second parameter tells genkernel to save the compiled kernel configuration into.


 * 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 <tt>.old</tt> 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, the  directory might look like this:

Configuring the bootloader
The symlinks presented above in the bootloader's configuration can be used so that, even if the new kernel is not bootable, the user can always boot on the old one.

To allow the kernel and intird provided by genkernel to run correctly, provide a minimum information in your bootloader 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 your bootloader initrd-aware.

Here is how the file might look.

Preserving your working files
The genkernel application automatically saves new changes to the files. If previous changes are to be preserved, then the following actions need to be taken.


 * The first file to preserve is the kernel configuration file in . If the source isn't changed prior to the recompilation of the kernel, the previously used name for this file will be used. So renaming the previous configuration file helps in preserving the information.


 * 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  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, first delete the new kernel image and remove the <tt>.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.

Using previous kernel configuration while changing the sources
The previous configuration can be used through the  option in your  as follows:

Network Booting with Genkernel from an Installation CD
The genkernel utility can build kernel and initrd images that provide support for network booting, or netbooting. With any luck, users should be able to netboot any recent computer into the environment provided by the Installation CD.

The magic lies in genkernel's linuxrc script: it will try to netmount the Installation CD using NFS. From there, the init scripts of the Installation CD can take over, as if the CD was present locally.

Building Kernel and Initrd Images with Support for Netbooting
To enable support for netbooting, include the following options while configuring the kernel:

First, the kernel image must include the drivers for your 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.

Be sure to select <tt>&lt;*&gt;</tt> and not <tt>&lt;M&gt;</tt>.

Secondly, it is suggested that IP: kernel level autoconfiguration is enabled as well as IP: DHCP support options. This avoids an unnecessary layer of complexity since the IP address and the NFS path to the Installation CD can be configured on a DHCP server. Of course, this means the kernel command line will remain constant for any machine — which is very important for etherbooting.

These options tell the kernel to send a DHCP request at bootup.

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.

Once the compilation process is completed, create a compressed tarball (tar.gz) that contains the kernel's modules. This step is only necessary if the kernel version does not match the kernel image version on the Installation CD.

To create an archive containing all the modules:

Depending on the network boot mechanism, one of the following steps need to be followed:

To create an etherboot image:

To create a OpenBoot / SPARC64 TFTP image:

The file is the boot image.

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 your platform.

NFS setup
To setup a NFS share that contains the Installation CD, use the loop device to mount the ISO image and then copy the contents of the CD into the NFS share. As a nice extra, genkernel's initrd scripts will extract all tar.gz files located in the directory. All that needs to be done here is copy the archive to the  directory.

The following assumes that is an exported NFS share:

Now copy the file into :

DHCP setup
The netboot images will ask the DHCP server on the network for an IP as well as a <tt>root-path</tt> parameter. Both can be specified per host using a MAC address to identify machines:

Netbooting Instructions
Netbooting itself is again very platform-specific. The important part is to specify the  and   parameters on the kernel command line, as this will bring up the network interface and tell the initrd scripts to mount the Installation CD via NFS. Here are some platform-specific tips.

For etherboot, insert the etherboot disk into the drive and reboot. The kernel command line was specified when the image was constructed. With Sparc64, hit - at the boot prompt and enter:

For PXE, setup pxelinux (part of syslinux), then create a along the lines of:

Introduction
If an initramfs is installed with genkernel, then take a look at the various boot options that can (or should) be defined in the bootloader configuration. The most common ones are added to this guide.

Loading LVM or software-RAID
If the system uses LVM or software-RAID, the initramfs has to be built using the <tt>--lvm</tt> and <tt>--mdadm</tt> options. Don't forget to enable support during boot as well. This can be done using the dolvm and domdadm options.

Booting in single-user mode
If for some reason boot-up fails, rescuing the system by booting in the single-user mode is still possible. This will only load the really necessary services and then drop the user to a rescue (root) shell.

Acknowledgements
We would like to thank the following authors and editors for their contributions to this guide:


 * Tim Yamin
 * Jimi Ayodele
 * Thomas Seiler
 * Joshua Saddler
 * Sebastian Pipping
 * José Fournier