Núcleo/Configuración

From Gentoo Wiki
< Kernel
Jump to:navigation Jump to:search
This page is a translated version of the page Kernel/Configuration and the translation is 40% complete.
Outdated translations are marked like this.

Este artículo describe la configuración manual y puesta en marcha del núcleo Linux. Eche un vistazo al artículo genkernel para conocer un método que configura valores seguros por defecto.

An alternative to manual configuration that uses 'safe defaults' to build a generic kernel are the distribution kernels.

Ajustar el enlace simbólico

El enlace simbólico /usr/src/linux debe apuntar siempre a los fuentes del núcleo que se está utilizando actualmente. Esto se puede hacer de tres formas:

1. Instalar los fuentes del núcleo con el ajuste USE symlink activo. Esto hará que /usr/src/linux apunte a los nuevos fuentes del núcleo instalado. En caso necesario se puede modificar más tarde mediante los siguientes dos métodos:

2. Ajustar el enlace simbólico con la herramienta eselect:

root #eselect kernel list
Available kernel symlink targets:
[1] linux-3.3.8-gentoo
[2] linux-3.4.9-gentoo

Esto muestra los fuentes del núcleo disponibles. El asterisco indica los fuentes seleccionados. Para cambiar estos fuentes, por ejemplo, a la segunda entrada, haga lo siguiente:

root #eselect kernel set 2

3. Ajustar el enlace simbólico manualmente:

root #ln -sf /usr/src/linux-3.4.9-gentoo /usr/src/linux
root #ls -l /usr/src/linux
lrwxrwxrwx 1 root root 11 Aug 29 22:10 /usr/src/linux -> /usr/src/linux-3.4.9-gentoo

Configuración

Herramientas

El núcleo ofrece varias herramientas de usuario con las cuales se puede configurar.

Command Description
make config Text based configuration. The options are prompted one after another. All options need to be answered, and out-of-order access to former options is not possible.
make menuconfig An ncurses-based pseudo-graphical menu (only text input). Navigate through the menu to modify the desired options.
make defconfig Generates a new config with default from the ARCH supplied defconfig file. Use this option to get back the default configuration file that came with the sources.
make nconfig Pseudo-graphical menu based on ncurses. Requires sys-libs/ncurses to be installed.
make xconfig Graphical menu using Qt5. Requires dev-qt/qtwidgets to be installed.
make gconfig Graphical menu using GTK. Requires x11-libs/gtk+ , dev-libs/glib , and gnome-base/libglade to be installed.
make oldconfig Review changes between kernel versions and update to create a new .config for the kernel.
make olddefconfig Generates a new configuration with default values from the ARCH supplied defconfig file while, at the same time, maintaining all the previous options set in the .config file found at /usr/src/linux/.config. This is a fast and safe method for upgrading a config file that has all the configuration options it needs for hardware support while at the same time gaining bug fixes and security patches.
make localmodconfig Creates a config based on the current config and the currently loaded modules, as viewable via the lsmod command.
make allyesconfig Enables all configuration options in the kernel. It will set all kernel options to *. Make sure a backup of the current kernel configuration is acquired before using this option!
make allmodconfig Enables all modules in kernel. Note that this operation will consume quite a bit of disk space.

También existen varios guiones para crear configuraciones por defecto de distintos tipos. Esto puede hacer que las configuración más complejas se realicen en menos tiempo. Lance la siguiente orden para mostrar una lista completa de las opciones de make:

root #make help

El resto de este artículo describe la configuración mediante la herramienta make menuconfig, sin embargo, el procedimiento es similar para las otras herramientas de construcción del núcleo.

root #cd /usr/src/linux
root #make menuconfig

Utilización

En el menú mostrado, la barra azul indica la posición del cursor. Puede cambiar esta posición con las teclas de movimiento del cursor y . La teclas de movimiento del cursor y expanden la barra de menú hacia abajo y definen lo que ocurre cuando se pulsa la tecla Intro. Para la barra de menú de abajo, Select cambia a un submenú de las entradas de menú que terminan en ---> mientras que Exit sale de un submenú. Como alternativa, se puede pulsar la tecla Esc dos veces para salir de la aplicación.

Al pulsar una tecla asociada a una letra A-Z se moverá la posición del cursor a las líneas que tienen estos caracteres en negrita. Las teclas Y, M y N se excluyen de esta forma de navegación ya que se utilizan para otros propósitos. Si una línea comienza por una Y, M o N, el siguiente carácter se mostrará en negrita y se podrá saltar a esa línea. Por ejemplo, relativo a la posición actual del cursor, si la siguiente línea muestra "Network Device Support --->", al pulsar la tecla E, se moverá el cursor a esa línea.

Los siguientes símbolos pueden aparecer al comienzo de las entradas en los menús:

Symbol(s) Description
[ ], [*] Options in square brackets can be activated or deactivated. The asterisk marks the menu entry as activated. The value can be changed with the space key. It is also possible to press Y key (Yes) to activate or N key (No) to deactivate the selected entry.


If the option is activated, the selected feature/driver will be built into the kernel and will always be available at boot time.

< >, <M>, <*> Options in angle brackets can be activated or deactivated, but also activated as module (indicated by a M). The values can be modified by pressing Y/N keys as before or by pressing the M key to activate the feature/driver as a module.


See the Kernel Modules article for differentiation.

{M}, {*} Options in curly brackets can be activated or activated as module but not be deactivated. This happens because another feature/driver is dependent on this feature.
-M-, -*- Options between hyphens are activated in the shown way by another feature/driver. There is no choice.

Más aún, algunas entradas de menú tienen una etiqueta al final:

Tag Description
(NEW) This driver is new in the kernel and is maybe not stable enough.
(EXPERIMENTAL) This driver is experimental and most likely not stable enough.
(DEPRECATED) This driver is deprecated and not needed for most systems.
(OBSOLETE) This driver is obsolete and should not be activated.

La mayoría de las opciones tienen una descripción que se puede ver pulsando la tecla H o eligiendo Help en la barra de menú.

Selección de controladores

Eche un vistazo al artículo sobre detección del hardware y a los artículos en la categoría Hardware.

Buscar módulos

Dentro de menuconfig utilice la tecla / para buscar módulos por su nombre.

Tal y como se muestra abajo, el resultado de la búsqueda mostrará números delante de los resultados. Si se pulsa 1 en el ejemplo de abajo make menuconfig saltará hasta la opción Bluetooth device drivers en la estructura del menú.

KERNEL Salida ejemplo después de buscar HCIBTUSB
Symbol: BT_HCIBTUSB [=m] 
Type : tristate 
Prompt: HCI USB driver 
 Location: 
 -> Networking support (NET [=y]) 
 -> Bluetooth subsystem support (BT [=y]) 
(1) -> Bluetooth device drivers 
 Defined at drivers/bluetooth/Kconfig:5 
 Depends on: NET [=y] && BT [=y] && USB [=m]

Habilitar los ajustes comunes de Gentoo Linux

Existe una opción de configuración del núcleo llamada CONFIG_GENTOO_LINUX que se encuentra disponible únicamente en sys-kernel/gentoo-sources y otros núcleos mantenidos por el proyecto del núcleo. Por sí misma no hace nada, sin embargo define algunas opciones de configuración que necesitan las instalaciones típicas.

Este ajuste selecciona automáticamente el soporte para tmpfs y devtmpfs que es necesario para gestionar /dev en Gentoo Linux. En el futuro puede que se expanda para permitir otros ajustes obligatorios en un sistema Gentoo Linux. Para más información, lea la ayuda disponible en el sistema de configuración del núcleo del sistema tal y como se describió antes en esta guía.

Kbuild

Advertencia
Be very careful of changing environment variables as it may break the kernel in unexpected ways. DO NOT MIX GNU binutils and LLVM binutils!!! For example make CC=gcc LD=ld.lld AR=llvm-ar will not work because LLVM's ar and ld is not compatible with GCC.

The Kernel build system can be used to change how Kernel builds in a more advanced way than make *config, similar to GNU Make. Kbuild also support Environment Variables like LLVM=1. For example, the kernel will be build with LLVM and with aggressive optimization flags:

root #make LLVM=1 KCFLAGS="-O3 -march=native -pipe"
Nota
Additional variables are explained in Clang/LLVM.

Construcción

Después de haber realizado correctamente la configuración, compile el núcleo:

root #make

-j$(nproc) tells make to use all available CPU cores to speed up compiling.

Configuración

Si se activaron controladores como módulos, se deberían instalar:

root #make modules_install

Los módulos se copiarán a un directorio de /lib/modules.

Nota
If you have enabled the dracut USE flag on sys-kernel/installkernel to automate initramfs generation during make install, it is recommended to run
root #emerge --ask @module-rebuild
before installing the kernel. This ensures that all external kernel modules (e.g., NVIDIA, ZFS) are rebuilt and included in the initramfs, preventing potential boot issues or missing functionality. Otherwise (if the flag isn't set), you can rebuild external modules later, but before regenerating the initramfs (e.g., using dracut --force). This ensures that the updated modules are included in the initramfs.

Para instalar el núcleo:

root #make install

Esta orden lanza /sbin/installkernel, que es parte del paquete sys-apps/debianutils . El nuevo núcleo se instala en /boot/vmlinuz-{versión}. Si ya existe un enlace simbólico /boot/vmlinuz éste se refresca haciendo un enlace simbólico desde /boot/vmlinuz al nuevo núcleo y el núcleo previamente instalado estará disponible como /boot/vmlinuz.old. (Página del manual de installkernel). Ocurre lo mismo para los ficheros config y System.map. Estos enlaces simbólicos son muy útiles ya que apunta siempre al último núcleo que se ha construido sin necesidad de cambiar la ruta a los ficheros (por ejemplo, se pueden utilizar en la configuración del cargador de arranque).

Cargador de arranque

Cambie la configuración del cargador de arranque del sistema para cargar el núcleo cuando arranque el sistema.

Cuando haya terminado el paso del cargador de arranque, reinicie el sistema con el nuevo núcleo.

Comparar la configuración actual del núcleo con la configuración por defecto

Utilice el siguiente procedimiento para tener una visión general de los ajustes de configuración del núcleo que se desvían de la configuración por defecto. Recuerde que la modificación de un ajuste en la configuración puede conllevar ajustes de configuración adicionales.

root #cd /usr/src/linux
root #cp -p .config ../.config.working
root #make defconfig
root #mv .config ../.config.default
root #cp -p ../.config.working .config
root #cd ..
root #/usr/src/linux/scripts/diffconfig .config.working .config.default > .config.diff

La función de búsqueda en make menuconfig se puede utilizar para buscar los símbolos y sus interpretaciones. Cuando haya terminado, limpie:

root #cd /usr/src/
root #rm .config.working .config.default .config.diff

Theming Menuconfig

It is possible to select different color schemes for menuconfig using the variable MENUCONFIG_COLOR. To select a theme use:

root #make MENUCONFIG_COLOR=<theme> menuconfig

Available themes are as follows:

Theme Description
mono Colors suitable for monochrome displays
blackbg A color scheme with black background
classic A color scheme with blue background. The classic look
bluetitle An LCD friendly version of classic. (default)

Veáse también

Recursos externos