For users who are not privy to kernel compilation, genkernel is a tool to automate this process. It can help you create a kernel image akin to those available on Gentoo Installation CDs, which are designed to auto-detect the hardware configuration of your system. Some users may also be interested in using genkernel for hardware requiring initialization and a working kernel before the system starts up. Since genkernel automatically compiles your kernel modules, you can use hardware that may require certain module parameters to be loaded for proper operation.
If you are either uncertain about how to compile a kernel, or are just unfamiliar with your hardware configuration, genkernel is a very handy tool. It is designed to take the pain out of the kernel compiling process, and supports most hardware by default.
However, if you know what drivers are required by your system, you may be able to further reduce the time taken to compile the kernel. This is possible since you can direct genkernel to only build drivers relevant to your hardware. Oftentimes, the number of drivers required by your system will be fewer (implying a shorter kernel compilation time) than the default configuration provides.
To obtain genkernel, run
Although there are several ways to run genkernel, the least-intrusive approach
is provided by
# genkernel --bootsplash --no-install --no-clean --menuconfig all
The above operation causes genkernel to create a bootsplash-enabled kernel
(
There are other flags which alter the result provided by genkernel. For
instance, replacing
Remember, genkernel is designed to make kernel compilation easy and stress-free. For this reason, genkernel features several flags to ease the kernel compilation effort. For example, there are flags to help with kernel configuration, while others affect the actual compilation. Some flags even help debug the compilation process. For those interested in further optimization, there are flags that affect kernel assembling, packaging and even kernel initialization.
The rest of this chapter examines the functionality of various flags and
actions available for genkernel. Some of the flags have variants which perform
a converse operation. The converse variants carry the
The configuration flags listed below exist to help you decide what features should be enabled or disabled in the kernel prior to compilation. You can even choose whether or not the configuration file created in the process should be saved. The following are the primary configuration flags:
The following flags usually take effect during the actual compilation:
The following flags are supported by genkernel, and are passed to the relevant
applications while the kernel is being assembled. These flags affect the
The use debugging flags during the kernel compilation process controls the amount of information reported, as well as the presentation of said data.
The flags here are used to create certain effects during system startup. Some of these flags are primarily for aesthetics, while others may be essential for enabling certain features on the system.
The assortment of flags listed below are supported by genkernel, but do not fit neatly into any of the other categories:
An action tells genkernel what to build. Currently, the following actions are supported:
The last action,
To set up genkernel to work with your bootloader, three or four changes should be applied to the bootloader's configuration file:
Passing flags to genkernel from the command line can be cumbersome, especially if you have about a dozen flags:
# genkernel --debuglevel=5 --no-color --no-mrproper --clean --gensplash \ --kerneldir=/path/to/alternate/kernel/sources --install --menuconfig \ --kernel-config=/path/to/preferred/configfile --save-config --mountboot all
Fortunately, there is a configuration file where most of the basic options can be set (or changed) as necessary. What follows is a rundown of the more relevant options:
By choosing the appropriate options in
# genkernel --gensplash --kerneldir=/path/to/alternate/kernel/sources \ --kernel-config=/path/to/preferred/configfile --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.
The genkernel utility can build kernel and initrd images that provide support
for network booting, or
The magic lies in genkernel's linuxrc script: it will try to
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 you have such drivers compiled directly into the kernel image and not as modules.
Device Drivers ---> Networking Support ---> Ethernet (10 or 100Mbit) ---> [*] Ethernet (10 or 100Mbit) <*> the driver for your network card(Be sure to select <*> and not <M>)
Secondly, we suggest that you enable
Device Drivers ---> Networking Support ---> Networking options [*] TCP/IP networking---> [*] IP: kernel level autoconfiguration [*] IP: DHCP support(These options tell the kernel to send a DHCP request at bootup.)
Additionally, you should 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
File systems---> Miscellaneous filesystems ---> [*] SquashFS 2.X - Squashed file system support
Once the compilation process is completed, create a compressed
(Create a tar.gz containing all the modules) # cd / # tar -cf /tmp/modules-X.Y.Z.tar.gz /lib/modules/X.Y.Z/
Depending on your network boot mechanism, you will need to do some of the following steps:
(Create an etherboot image) # emerge mknbi # cd /boot # mkelf-linux -params="root=/dev/ram0 init=/linuxrc ip=dhcp" kernel... initrd... > etherboot.img(Create a OpenBoot / SPARC64 TFTP image) # 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 need any more steps, the kernel and initrd can be used as is)
Finally, copy this kernel to your TFTP server. The details are architecture-dependent and are beyond the scope of this guide. Please refer to the documentation for your platform.
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
(This assumes that /nfs/livecd is a exported NFS share) # mount /tmp/gentoo-livecd.iso /mnt/cdrom -o loop # cp -p /mnt/cdrom /nfs/livecd # umount /mnt/cdrom(Copy the modules.tar.gz into /add) # mkdir /nfs/livecd/add # cp /tmp/modules-X.Y.Z.tar.gz /nfs/livecd/add
The netboot images will ask your DHCP server for an IP as well as a root-path parameter. Both can be specified per host using a MAC address to identify machines:
... host netbootableMachine { hardware ethernet 11:22:33:44:55:66; fixed-address 192.168.1.10; option root-path "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 netbooted machine ...
Netbooting itself is again very platform-specific. The important part is to
specify the
# Etherboot - insert the etherboot disk into the drive and reboot # The kernel command line was specified when the image was constructed # Sparc64 - Hit Stop-A at the boot prompt ok boot net ip=dhcp init=/linuxrc# PXE - Setup pxelinux (part of syslinux), then create a pxelinux.cfg/default along the lines of: DEFAULT gentoo TIMEOUT 40 PROMPT 1 LABEL gentoo KERNEL kernel-X.Y.Z APPEND initrd=initrd-X.Y.Z root=/dev/ram0 init=/linuxrc ip=dhcp
The purpose of genkernel is to provide an (easier) alternative to the time-tested approach to kernel compilation. As always, you are free to decide on whether or not you want to automate the kernel compilation process.