The kernel is the heart of a Linux system. Although the following sections
will not teach you how to be a kernel ``hacker'', they will tell you how
to install a SuSE update kernel and
introduce the basics of compiling a customized kernel. If you
proceed as outlined in this chapter, you can keep your current
functional kernel. Later, if your new kernel works as desired,
change it to the default.
The standard SuSE kernel, located in the directory /boot, is configured to support as wide a range of hardware as possible. There is no need to compile your own kernel, unless you want to test experimental features and drivers. Several Makefiles are provided with the kernel to automate the process. All you need to do is select the hardware settings and other kernel features. As you need to know your computer system pretty well to make the right selections, we recommend modifying an existing and working configuration file for your first attempt.
To install an official SuSE update kernel, download the update rpm from the SuSE FTP server or a mirror like ftp://ftp.gwdg.de/pub/linux/suse/. If you want to find out your current kernel version, you have several possibilities to do so. You may just look at the version string:
You may also check which package the kernel (/boot/vmlinuz) belongs to:
Before installing this package, it is recommended to save the current kernel and initrd under a different name. As SuSE @nohyphen root, enter the following two commands:
cp /boot/vmlinuz /boot/vmlinuz.old
cp /boot/initrd /boot/initrd.old
Now, install the new kernel with the command
Since SuSE Linux 7.3, reiserfs is the standard file system. It requires the use of an ``initial ramdisk''. Therefore, use the command mk_initrd to write the new initial ramdisk. In current SuSE Linux versions this is done automatically when installing the new kernel.
To be able to boot the old kernel, configure the boot loader accordingly (for more information refer to 4). Finally, reboot to load the new kernel.
To reinstall the original kernel from the SuSE Linux CDs, the procedure is almost the same, except you copy the kernel rpm from the directory boot on CD 1 or the DVD. Now, install as described above. If you receive an error message saying that a newer kernel rpm is already installed, add the option -force to the above rpm command.
To build a kernel, the package kernel-source must be installed. Additional packages, like the C compiler (package gcc), the GNU binutils (package binutils), and the include files for the C compiler (package glibc-devel), are selected for installation automatically by YaST.
After installation, the kernel sources are located in /usr/src/linux-<kernel-version>.SuSE. If you plan to experiment with different kernels, unpack them in different subdirectories and create a symbolic link to the current kernel source. As there are software packages that rely on the sources being in /usr/src/linux, maintain this directory as a symbolic link to your current kernel source. YaST does this automatically.
The most recently compiled configuration is stored in the file /boot/vmlinuz.config. To modify the configuration of the currently-used kernel, go to the directory /usr/src/linux as user SuSE @nohyphen root and enter make cloneconfig to generate the file .config. Alternatively, copy the configuration file with the command cp /boot/vmlinuz.config .config.
The kernel configuration tools will read the file .config and offer all settings for modification. The kernel can be configured at the command line, in a menu in text-mode, or in a menu in the X Window System. The following is a short overview of these three methods.
To configure the kernel, make sure your working directory is /usr/src/linux and enter make config. Choose the options you want supported by the kernel. There are two or three possibilities: Y, N, or M. `m' means that this device is not compiled directly into the kernel, but loaded as a module instead. Any driver needed to boot the system should be integrated into the kernel, not loaded as a module. With , confirm the default settings read from the file .config. Pressing any other key accesses a short help text about the current option.
A much more convenient way of configuring the kernel is to use make menuconfig. With menuconfig, you do not have to go through all the questions.
Instead, select the areas of interest from the menu. The default settings are read from the file .config. To load another configuration, select ` Load an Alternate Configuration File' and enter the file name.
If you have installed and configured the X Window System ( package xf86) and Tcl/Tk (package tcl and package tk), you can use make xconfig. It uses a GUI (Graphical User Interface) that makes kernel configuration very user-friendly. If you have not logged in to the X Window System as SuSE @nohyphen root, enter the command xhost +localhost (replacing localhost with the name of the local host) to allow SuSE @nohyphen root to take over the display. The default settings are taken from the file /usr/src/linux/.config. Please consider that the grafical configuration with xconfig is not as well maintained as the other configuration possibilities. Therefore you should run the command make oldconfig after configuring the kernel.
Do not forget to regenerate the kernel dependencies after you reconfigure the kernel. Regardless of the configuration method you should issue the following command after finishing with your configuration:
This is especially necessary if you want to build kernel modules for commercial software.
There is a wide variety of PC hardware components. To use this hardware properly, you need a ``driver'' with which the operating system (in Linux, the ``kernel''), can access this hardware. There are basically two ways of integrating drivers into your system:
Which drivers to compile into the kernel and which to load as run-time modules is defined in the kernel configuration. Basically, components not required for booting the system should be built as modules. This makes sure the kernel does not get too big to be loaded by the BIOS or a boot loader. Drivers for ext2, the SCSI drivers on a SCSI-based system, and similar drivers should be compiled into the kernel. In contrast, items such as isofs, msdos, or sound, which are not needed for starting your computer system, should definitely be built as modules. Kernel modules are located in /lib/modules/<Version>, where <Version> is the current kernel version.
Within SuSE Linux the program hwinfo is at your disposal that can not only detect the hardware of your system, but also select the drivers that are needed to run this hardware. You get a small introduction to this command with:
If you need e.g. information about your SCSI-Devices, you may use the command:
All of this information is also available in YaST in the module hardware information.
The following commands are available:
/etc/modules.conf affects how modules are loaded. Refer to the man page for depmod (man depmod).
Enter the parameters for modules that access hardware directly in this file. Such modules may need system-specific options (e.g. , CD-ROM driver or network driver). The parameters entered here are, for the most part, identical to those given to the boot prompt of the kernel. However, in many cases the names used at the boot prompt are different. If a module failed to load, try specifying the hardware in this file and use modprobe instead of insmod to load the module.
The kernel module loader is the most elegant way to use modules. Kmod performs background monitoring and makes sure the required modules are loaded by modprobe as soon as the respective functionality is needed in the kernel.
To use Kmod, set the corresponding variable in the kernel configuration ` Kernel module loader' (CONFIG_KMOD). Kmod is not designed to automatically unload modules. The potential saving in memory is only marginal for the RAM capacity of computers today. See also /usr/src/linux/Documentation/kmod.txt. For reasons of performance, it is better for server machines, which have special tasks to perform and need only a few drivers, to have a ``monolithic'' kernel.
All the kernel's configuration options cannot be covered here in detail. Make use of the numerous help texts available on kernel configuration. The latest kernel documentation is always in /usr/src/linux/Documentation.
We recommend compiling a ``bzImage''. As a rule, this avoids the problem of the kernel getting too large, as can easily happen if you select too many features and create a ``zImage''. You will then get error messages like kernel too big or System is too big.
After customizing the kernel configuration, start compilation by entering:
These three commands can be entered on one line as well:
earth :/usr/src/linux# make dep clean bzImage
After a successful compilation, you will find the compressed kernel in /usr/src/linux/arch/i386/boot
. The kernel image -- the file that contains the kernel -- is called bzImage
. If you cannot find this file, an error probably occurred during the kernel compilation. In the Bash shell, enter the following command to launch the kernel compilation again and write the output to a file kernel.out:
earth :/usr/src/linux# make bzImage 2>&1 | tee kernel.out
If you have configured parts of your kernel to load as modules, launch the module compilation. Do this with make modules.
After the kernel is compiled, it must be installed so it can be booted. If you use LILO, LILO must be updated as well. To prevent unpleasant surprises, it is recommended that you keep the old kernel (e.g., as /boot/vmlinuz.old), so you can still boot it if the new kernel does not function as expected:
earth :/usr/src/linux# cp /boot/vmlinuz /boot/vmlinuz.old
earth :/usr/src/linux# cp arch/i386/boot/bzImage /boot/vmlinuz
earth :/usr/src/linux# lilo
The Makefile target make bzlilo performs these three steps in one go.
Note
If you are using GRUB as the boot loader, it does not need to be
reinstalled. Therefore only carry out the first two steps to copy
the kernel to the right place in the system.
Now the compiled modules need to be installed. By entering:
copy these to the correct directories in /lib/modules/<Version>. This overwrites the old modules with the same kernel version. However, the original modules can be reinstalled together with the kernel from the CDs.
Tip
You should make sure that modules whose functionality may now
have been directly compiled into the kernel are removed from
/lib/modules/<Version>. Otherwise, unexpected
effects could occur. This is one reason why the inexperienced user is
strongly advised against compiling the kernel.
To enable GRUB or LILO to boot the old kernel (now /boot/vmlinuz.old), add an image entry with label Linux.old in your /boot/grub/menu.lst or /etc/lilo.conf respectively. This procedure is described in detail in 4. When you have adapted /etc/lilo.conf to your needs, enter lilo. If you are using LILO as the boot loader, LILO must be reinstalled after modifications to /etc/lilo.conf with the command lilo. GRUB does not need to be reinstalled.
The file /System.map contains kernel symbols required by the modules to ensure successful launching of kernel functions. This file depends on the current kernel. Therefore, once you have compiled and installed the kernel, copy /usr/src/linux/System.map to the directory (/boot). This file is regenerated each time the kernel is recompiled. If you create your kernel using make bzlilo or make zlilo, this is done for you automatically. If you get an error message like System.map does not match current kernel, System.map probably has not been copied.
If you are low on hard disk space, delete the object files generated during kernel compilation using make clean in the /usr/src/linux directory. If you have plenty of disk space and plan to reconfigure the kernel on a regular basis, you might want to skip this. Recompiling the kernel is considerably faster then, because only the parts affected by changes will actually be recompiled.