Meniu

Genkernel Guide for Gentoo Linux

For users unfamiliar with kernel compilation, genkernel is a utility for automating this process. It can help you create a kernel image similar to those available on Gentoo's Installation CD media, which are designed to automatically detect your system's hardware configuration. Some users may also be interested in using genkernel to initialize hardware needs. of a functional kernel before starting the system. Because genkernel automatically compiles your kernel modules, you can use hardware components that may require certain module parameters to be loaded for proper operation.

Ink audience

If you are either unsure about how to compile a kernel, or are just unfamiliar with the hardware configuration, genkernel is a very handy utility. It is designed to remove the hassle of the kernel compilation process and supports most hardware components, by default.

However, if you want to know what drivers are required for your system, you may be able to reduce kernel compilation time. This is possible because you can specify the genkernel utility to compile only drivers that are relevant to your hardware. Often, the number of drivers required for your system will be smaller (involving a shorter kernel compile time) than the default configuration provided.

Installing genkernel

To get the genkernel, run emerge genkernel from the command line. If you are using the Gentoo Reference Platform (GRP), remember to install the binary packages by adding the -k option to the emerge command. Because GRP packages contain an old version of genkernel, the options may differ. In any case, see genkernel --help to see how to use the version of genkernel installed on your system.

Working with genkernel

How to use genkernel

Although there are several ways to run genkernel, the least intrusive approach is offered by genkernel all. In this case, a generic configuration that works correctly on most systems is used. As mentioned earlier, this approach is not without its disadvantages; most of the modules created are useless to the common user and can increase compilation time. Below is an illustration of a more efficient approach, obtained by passing certain options to the genkernel utility, as root:

Running genkernel (with other options)

# genkernel --bootsplash --no-install --no-clean --menuconfig all

The above operation causes the genkernel to create a kernel with bootsplash enabled (--bootsplash) that will need to be installed manually (--no-install). While preparing the kernel source structure, genkernel will not clean any existing modules present in the source structure (--no-clean). A menu-based kernel configuration utility will be displayed to allow the user to select which modules will be compiled for the system (--menuconfig).

There are other options that change the result provided by genkernel. For example, replacing the --no install option with the --install option allows the genkernel utility to automatically install the new kernel image in the / boot directory. Using the --mountboot option allows the genkernel utility to mount your / boot partition automatically, if necessary.

Remember, genkernel is designed to make your kernel compilation considerably easier. For this reason, genkernel has some options to ease the kernel compilation effort. For example, there are options to help configure the kernel, while other options affect the actual compilation. Some options will even help you troubleshoot the compilation process. For those interested in future optimizations, there are options that affect kernel assembly, packaging, and even kernel initialization.

The rest of this chapter examines the functionality of various options and actions available for genkernel. Some of these options have variants that perform a convergent operation. Convergent variants have the prefix no- and their effects are displayed in square brackets, [].

Configuration Options

The configuration options displayed below are present to help you decide which features to enable and which not in the kernel before compilation. You can even choose whether the configuration file is saved or not. The following options are especially configuration:

--no-menuconfig: Enables [or disables] the make menuconfig command (which invokes an interactive, menu-based kernel configuration utility) before compiling the kernel.
--gconfig: Provides the kernel configuration utility that depends on GTK + libraries. The advantage of this option is that most users find it easier and clearer to configure the kernel by using this utility, because it is based on the X windows system. The disadvantage of this option is that you need the X windows system to use it, so will not work on the command line.
--xconfig: Provides a kernel configuration utility that depends on QT libraries. The advantage of this option is that most users find it easier and clearer to configure the kernel by using this utility, because it is based on the windows system X. The disadvantage of this option is that you need the X window system 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.

Compilation Options

The following options usually take effect during the actual compilation:

--kerneldir = / path / to / sources /: Specifies an alternate location of kernel sources, instead of the default one, / usr / src / linux /.
--kernel-config = / path / to / configuration-file: Specifies which alternative kernel configuration will be used, instead of the default file, /path/to/sources/.config.
--module-prefix = / path / to / prefix-directory /: Specifies a prefix to the directory where the kernel modules will be installed (the default path is the / lib / modules / directory.)

--no-clean: Enables [or disables] the make clean command before compiling your kernel. The make clean command removes all object files and dependencies from the kernel source structure.
--no-mrproper: Enables [or disables] the make mrproper command before compiling the kernel. Like the make clean command, make mrproper removes all object files and dependencies from the kernel source structure. However, any previous configuration files (from /path/to/sources/.config or /path/to/sources/.config.old) will also be removed from the kernel source structure.
--oldconfig: Executes the make oldconfig command, which tries to collect configuration information for the system architecture from a generic script in / usr / share / genkernel /. This is a non-interactive process; nothing is required from the user. Also, if --oldconfig is used in conjunction with --clean, the last option is denied, resulting in activating the --no-clean option.

--callback = "echo hello": Executes the specified arguments (echo hello, in this case) after the kernel and relevant modules have been built, but before compiling the initrd image. This can be useful if you want to install external modules in the initrd image by installing the relevant packages using emerge using the callback option, and then redefining a group of genkernel modules.

--no-install: Enables [or disables] the make install command, which installs your new kernel image, configuration file, initrd image, and system map into your boot-mounted partition. Any compiled modules will be installed as well.
--no-initrdmodules: Stops the operation of copying any module into the initrd image created by genkernel. This option is an exception to the no-prefix rule; omitting this prefix creates an invalid kernel option.
--genzimage: Create an initrd image, before the kernel image (This trick currently only applies to Pegasos PPC systems.)

Compiler Options

The following options are supported by the genkernel, and are passed to the relevant applications while the kernel is assembled. These options affect the compiler used for the kernel compilation process, but at a much lower level.

--kernel-cc = aCompilerName: Specifies a compiler invoked during the kernel compilation process.
--kernel-ld = aNameLinkEditor: Specifies a link editor invoked during the kernel compilation process.
--kernel-as = anAssemblerName: Specifies the assembly application invoked during the kernel compilation process.
--kernel-make = oMakeAppName: Specifies an alternative to the GNU make utility invoked during the kernel compilation process.

--utils-cc = aCompilerName: Specifies the compiler application invoked while compiling support utilities.
--utils-ld = aNameLink Editor: Specifies the link editor invoked while compiling support utilities.
--utils-as = anAssemblerName: Specifies the assembly application invoked while compiling support utilities.
--utils-make = oMakeApplicationName: Specifies an alternative to the GNU make utility invoked while compiling support utilities.

--makeopts = -jX: Specifies the number of concurrent threads that can be implemented by the make application while the kernel (and utilities) are being compiled. The variable 'X' is the number obtained by adding the number one (1) to the number of processors used by the system. So for a single processor system, the right option is -j2; a system with two processors will use the -j3 option, and so on. (A single-processor system that supports Hyper-Threading Technology (HT) can use the -j3 option provided by kernel-enabled Symmetric Multi-Processing (SMP) support.)

Troubleshooting Options

Using debugging options during the kernel compilation process controls the amount of information reported, as well as the presentation of the indicated data.

--debuglevel = verblevel: Controls the level of information for genkernel data. The verblevel variable is an integer between 0 and 5. Level '0' is the minimum display, while '5' provides as much information as possible about genkernel activities during the kernel compilation process.
--debugfile = / path / to / output-file: Ignore the value set by the --debuglevel argument and transmit all debug data produced by genkernel in the specified output file, which is stored in /var/log/genkernel.log , default.
--no-color: Enables [or disables] the color display of debugging information (reported by genkernel) using escape sequences.

Initialization Options

The options shown here are used to create certain effects during system startup. Some of these options are primarily for aesthetics, while others may be essential for activating certain functionalities in the system.

--no-bootsplash: Enables [or disables] bootplash support in the initrd image compiled by genkernel. Bootplash functionality is supported on a small number of architectures, and a kernel that supports bootsplash is also required.
--no-gensplash: Enables [or disables] gensplash support in the initrd image compiled by genkernel. The gensplash utility is intended as a replacement for bootsplash and is designed for use in the 2.6.x kernel series. To override the default theme used by gensplash, use --gensplash = Favorite Theme (where Favorite Theme is the title of one of the directories in the / etc / splash / location.
--gensplash-res = Preferred Resolution: This option allows you to select which splash image display resolutions will be supported by the initrd image during system startup. This is useful for two reasons: First, you can select only splash image display resolutions that are relevant to your system. Second, you avoid unnecessarily increasing the disk space required by the initrd image (because initrd does not need to support resolutions irrelevant to your system) However, you can omit this option if the kernel is built for an Installation CD environment; this allows gensplash support for all possible resolutions.
--do-keymap-auto: Forces the selection of keystrokes during the boot sequence.
--lvm2: Includes support for storage via Logical Volume Management (LVM2) from static binaries, if available for the system. Relevant (static) LVM2 binaries are compiled, if not available. Be sure to install the lvm2 package on your system, with emerge lvm2 before activating this option, and consult the guide for Installing LVM2 in Gentoo.
--evms2: Includes storage media using Enterprise Volume Management System (EVMS2), if available. Be sure to install the evms package on your system with USE = static emerge evms2 before using this option (genkernel). (Omitting the USE = static indicator during package installation will not be able to include the required static binaries, causing an error.)
--dmraid: Includes support for DMRAID; the utility that creates RAID schemas using the kernel device-mapper subsystem. DMRAID discovers, activates, deactivates and displays properties of RAID software sets (ATARAID, for example) and the DOS partitions contained.
--linuxrc = / path / to / your / script / linuxrc: Specify a custom created linuxrc script? a script that is initialized during the boot stage of a kernel, before the actual boot process. (A default linuxrc file should be in the / usr / share / genkernel / directory.) This script allows you to boot into a small, modularized kernel and load the necessary system drivers (as modules).
--cachedir = / path / to / other / directory /: Overrides the default cache location, used during kernel compilation.
--tempdir = / path / to / new / temporary-directory /: Specifies the location of the temporary directory used by genkernel during kernel compilation.
--unionfs: Includes support for the Unification File System in the initrd image.

Various options

The options shown below are supported by genkernel, but do not fit perfectly into any of the other categories:

--mountboot: Detects whether or not the / boot / directory should be mounted on a separate partition. It will check the / etc / fstab script for instructions on how to mount the boot partition on a file system (if needed).
--kernname = Name: Allows you to change the name of the kernel and initrd images in the / boot / directory, so that the images produced are kernel-Version-Name and initramfs-Version-Name.

Possible Actions

An action specifies to the genkernel utility what to build. Currently, the following actions are supported:

initrd: Build only the image initrd
bzImage: Build only the kernel image
kernel: Build only the kernel image and modules
all: Build all stages? initrd image, kernel image and modules.

The last action, all, is recommended for most users, because it builds the stages needed for a functional kernel. Remember, an action only specifies to the genkernel application what to build, not what to install.

Bootloader Application Configuration

To set genkernel to work with your bootloader application, three or four steps must be applied to your bootloader application configuration file:

Add root = / dev / ram0 and init = / linuxrc to the kernel parameters that are passed to the kernel image.
Add real_root = / dev / hda3, for example, to kernel parameters passed to the kernel image, if / dev / hda3 contains your root partition.
If you use bootsplash, add a mode like vga = 0x317 to the parameters passed to the kernel image and also add splash = verbose or splash = silent depending on the level of information required in your bootloader application.
Add the initrd information as required by the bootloader application. See the Chapter on Configuring the Bootloader Application in the Gentoo Handbook for details on how to configure your bootloader application to be able to load initrd images.

Configuration Options

Editing /etc/genkernel.conf

Transmitting options to the command line genkernel utility can be cumbersome, especially when you have a dozen parameters:

Running genkernel (overloaded with options)

# genkernel --debuglevel=5 --no-color --no-mrproper --clean --gensplash \ --kerneldir=/calea/catre/surse/de/kernel/alternative --install --menuconfig \ --kernel-config=/calea/catre/fisierul-de-configurare/preferat --save-config --mountboot all

Fortunately, there is a configuration file where most of the basic options can be set (or modified) as needed. The following is a review of the most relevant options:

MENUCONFIG = [yes | no]: This option is equivalent to the --menuconfig parameter used by the genkernel, which in turn uses the make menuconfig command to invoke the command line kernel configuration utility. To invoke the automatic utility during kernel configuration using this script, set the 'yes' option here; otherwise, choose 'no'.
CLEAN = [yes | no]: Setting this option to 'yes' is equivalent to the --clean parameter used by genkernel, and invokes the make clean command that deletes all object files and dependencies in the kernel source structure. Does setting this 'no' value option create a cascading effect? is equivalent to the --no-clean parameter in genkernel, what disables the --no-mrproper genkernel parameter? essentially canceling the make mrproper command.
MRPROPER = [yes | no]: Setting this option to 'yes' is equivalent to the --mrproper parameter used by genkernel, and invokes the make mrproper command, which deletes the kernel source structure of configuration files. Selecting 'no' here is equivalent to the --no-mrproper parameter in genkernel, which disables the make mrproper command.
MOUNTBOOT = [yes | no]: Setting this option to 'yes' is equivalent to the --mountboot parameter and automatically mounts the / boot / directory (if necessary) during compilation. If the / boot / directory is stored on another partition, consider enabling this option; will cause a minus (essential) step to be performed later.
SAVE_CONFIG = [yes | no]: After configuring the kernel, the selected options are stored as a .config file in the kernel source structure. This script can be overwritten during the next kernel compilation, or even removed from the kernel source structure. Choosing 'yes' here is equivalent to the --save-config parameter and stores all the options selected during kernel configuration as a script in the / etc / kernels / directory. Choosing the value 'no' preserves the status quo.
USECOLOR = [yes | no]: Setting this option to 'yes' is equivalent to the --color parameter that colors the text displayed by the genkernel, to make the debugging process easier (if necessary.)
DEBUGLEVEL = [0 | 1 | 2 | 3 | 4 | 5]: Is this option to adjust the level of information of genkernel-produced texts? setting this option to '0' with --debuglevel = 0 will remove all text produced by genkernel; setting this option to '5' with --debuglevel = 5 gives the user all the text produced by genkernel.

By choosing the appropriate options in /etc/genkernel.conf, you can halve the number of parameters passed to the genkernel application from the command line:

Running genkernel (with options), after configuring genkernel.conf

# genkernel --gensplash --kerneldir = / path / to / alternative / kernel / sources \ --kernel-config = / path / to / preferred / configuration-file --install all

Identical results are obtained from both approaches, but the latter has most of the options stored in a script that can be modified at a later date.

Genkernel Network Boot Process

The Network Boot process on an Installation CD

The genkernel utility can build kernel and initrd images that support the network boot process, or the netbooting process. With any luck, you should be able to boot from the network on a recent system in the environment provided by the Installation CD.

The magic lies in the linuxrc script in genkernel: it will try to use netmount for the Installation CD using NFS. From there, the initialization scripts on the Installation CD can take over the process, as if the CD were present locally.

Building Kernel and Initrd Images with Support for the Network Boot Process

To enable support for the network boot process, include the following options during kernel configuration:

Warning: Support for the network boot process is experimental and may contain errors.

First, the kernel image must include drivers for your Network Interface Cards (NICs). Normally, the drivers for such devices will be compiled as modules. However, it is essential (for the network boot process) to compile these drivers directly into the kernel image and not as modules.

Configuring a 2.6.x kernel series to support your network card driver

Device Drivers ---> Networking Support ---> Ethernet (10 or 100Mbit) ---> [*] Ethernet (10 or 100Mbit) <*> driver for your network card (Be sure to select < *> and no)

Then, we suggest you enable the IP: kernel level autoconfiguration and IP: DHCP support options. This avoids an unnecessary level of complexity, as the IP address and NFS path to the Installation CD environment can be configured on a DHCP server. Of course, does this mean that the kernel command line will remain constant for any machine? which is very important for the etherbooting process.

Configuring a 2.6.x kernel suite to support DHCP

Device Drivers ---> Networking Support ---> Networking options [*] TCP / IP networking ---> [*] IP: kernel level autoconfiguration [*] IP: DHCP support (These options specify the kernel to send a DHCP request at boot.)

Additionally, you could enable SquashFS, as most modern Gentoo Installation CD media require it. SquashFS support is not included in the generic kernel source structure. To enable SquashFS, apply the necessary patches to generic kernel sources or install gentoo-sources.

Configuring the kernel to support SquashFS

File systems ---> Miscellaneous filesystems ---> [*] SquashFS 2.X - Squashed file system support

Once the compilation process is complete, create a tarball archive (tar.gz) that contains the kernel modules. This step is only necessary if your kernel version does not match the version of the kernel image on the Installation CD.

Creating a tarball archive containing kernel modules

(Create a tar.gz file containing all the modules) # cd / # tar -cf /tmp/modules-XYZtar.gz / lib / modules / XYZ /

Depending on the network boot mechanism, you will need to perform some of the following steps:

Creating a boot image

(Create an etherboot image) # emerge mknbi # cd / boot # mkelf-linux -params = "root = / dev / ram0 init = / linuxrc ip = dhcp" kernel ... initrd ...> etherboot.img (Create a imagine OpenBoot / SPARC64 TFTP) # emerge sparc-utils # cd / boot # elftoaout kernel ... -o kernel.aout # piggyback64 kernel.aout System.map -... initrd -... # mv kernel.aout openboot. img (This is the boot image) (PXE does not require any additional steps, kernel and initrd images can be used as such)

Finally, copy this kernel to your TFTP server. The details are dependent on the architecture and are not the purpose of this guide. Please consult the documentation specific to your platform.

NFS setting

To set up an NFS shared directory that contains the Installation CD environment, use the loop device to mount the ISO image, and then copy the contents of the CD environment to the NFS shared directory. As a useful extra option, the scripts in the initrd image of genkernel will extract all tar.gz files stored in the / nfs / livecd / add / directory. All you have to do now is copy the modules-XYZtar.gz archive to the / nfs / livecd / add / directory.

Preparing the NFS shared directory

(This assumes that / nfs / livecd is an exported NFS shared directory) # mount /tmp/gentoo-livecd.iso / mnt / cdrom -o loop # cp -p / mnt / cdrom / nfs / livecd # umount / mnt / cdrom (Copy modules.tar.gz to / add) # mkdir / nfs / livecd / add # cp /tmp/modules-XYZtar.gz / nfs / livecd / add

DHCP setting

Netboot images will ask the DHCP server for an IP address, as well as a root-path parameter. Both can be specified depending on the host system using the MAC address to identify the machines:

Code Listing 4.7: Setting the sample dhcpd.conf client file

... host netbootableMachine {hardware ethernet 11: 22: 33: 44: 55: 66; fixed-address 192.168.1.10; root-path option "192.168.1.2:/nfs/livecd"; } # Here, 192.168.1.2 is the NFS server # While 192.168.1.10 will be the IP address of the machine booting from the network ...

Network Boot Process Instructions

The boot process of the network itself is, again, very dependent on the platform. The important part is to specify the ip = dhcp and init = / linuxrc parameters of the kernel command line, as this will activate the network interface and specify the initrd scripts to mount the Installation CD environment via NFS. Here are some platform-dependent tips:

Network Boot Process Instructions

# Etherboot - insert the etherboot disk into the drive and restart # The kernel command line was specified when building the image # Sparc64 - Click Stop-A at the boot prompt ok boot net ip = dhcp init = / linuxrc # PXE - Set pxelinux ( part of syslinux), then create a pxelinux.cfg / default file containing the lines: DEFAULT gentoo TIMEOUT 40 PROMPT 1 LABEL gentoo KERNEL kernel-XYZ APPEND initrd = initrd-XYZ root = / dev / ram0 init = / linuxrc ip = dhcp

conclusions

To Automate or Not to Automate?

The purpose of the genkernel utility is to provide an (easier) time-consuming alternative to compiling the kernel. As always, you are free to decide whether or not you want to automate the kernel compilation process.

John Doe

Articole publicate de la contributori ce nu detin un cont pe gnulinux.ro. Continutul este verificat sumar, iar raspunderea apartine contributorilor.
  • | 340 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign