14.5. Installing the new kernel

With your kernel now successfully compiled, all you need to do now is install it. Again for the sake of cleanliness and to identify your kernels unambiguously, it is preferable to maintain a certain discipline in naming. Let us assume that you are installing a 2.2.17 kernel. The types of commands are as follows:

$ make install

After this, you still have to update the Boot Loader you use. There are two main possibilities: GRUB or LILO. Note that Linux-Mandrake is now shipped with GRUB as the default Boot Loader.

14.5.1. Updating GRUB

Obviously, retain the possibility of starting your current kernel! The simplest way of updating GRUB is to use DrakBoot (see chapter DrakBoot: change your boot-up settings at the User Guide). Alternatively, you can manually edit the configuration file as follows.

You now need to edit the file /boot/grub/menu.lst. This is what a typical menu.lst looks like, after you have installed your Linux-Mandrake distribution and before modification:

timeout 5
color black/cyan yellow/cyan
i18n (hd0,4)/boot/grub/messages
keytable (hd0,4)/boot/fr-latin1.klt
default 0

title linux
kernel (hd0,4)/boot/vmlinuz root=/dev/hda5  

title failsafe
kernel (hd0,4)/boot/vmlinuz root=/dev/hda5  failsafe 

title Windows
root (hd0,0)
makeactive
chainloader  +1 

title floppy
root (fd0)
chainloader +1

This file is made of two parts: the header with common options (the five first lines), and the sections (or entries), each one corresponding to a different GNU/Linux kernel or whatever OS. timeout 5 defines the time you have to choose a particular option before GRUB launches the default. This default is defined by default 0, which means that the first section defined is the default one. The color line defines the menu colors; The i18n line defines where to read the welcome message: (hd0,4) means that it is located on the fifth partition of the first hard disk. The option keytable (hd0,4)/boot/fr-latin1.klt Tells GRUB the keyboard type used when you give it arguments at boot time.

Then comes the entries section. We've got here four of them: linux, failsafe, windows, and floppy.

  1. The option line for linux's section tells GRUB that we want to load the primary boot image called vmlinuz in the directory /boot/ of the fourth partition of the first hard disk. The option root=/dev/hda5 is not a GRUB option, it is in fact passed to the kernel to inform it that the root filesystem (/) is located on /dev/hda5.

  2. The failsafe entry resembles a lot the previous one, apart that we will pass an argument to the kernel (failsafe) which tells it to enter "single" or "rescue" mode.

  3. The Windows entry direct GRUB to simply load the boot sector of the first partition, which probably contains a Windows boot sector.

  4. The last entry floppy simply boots your system from the floppy disk in the first drive, whatever the system installed on it.

Note

Depending on the security level you use on your system, some of the entries described here may be absent in your file.

Now to the point. We need to add another GNU/Linux section in order to start with the new kernel. In this example, it will be placed before the other entries, but nothing prevents you from putting it somewhere else:

title linux-experimental
kernel (hd0,4)/boot/vmlinuz-2.2.17 root=/dev/hda5  

Don't forget to adapt the file to your configuration! The GNU/Linux root filesystem here is /dev/hda5 but it may well be somewhere else on your system. Your system is ready, you may reboot your computer and enjoy your brand new kernel!

If you compiled your kernel with the framebuffer, you will probably want to use it: in this case, you need to add a directive to the kernel which tells it what resolution you want to start in. The list of modes is available in the file /usr/src/linux/Documentation/fb/vesafb.txt (only in the case of the VESA framebuffer! Otherwise, refer to the corresponding file). For the 800x600 mode in 32 bits[1], the mode number is 0x315, so you need to add the directive:
vga=0x315
and your entry now resembles:
title linux-experimental
kernel (hd0,4)/boot/vmlinuz-2.2.17 root=/dev/hda5 vga=0x315 

For more information, please consult the info pages about GRUB (info grub).

14.5.2. Updating LILO

The simplest way of updating LILO is to use DrakBoot (see chapter DrakBoot: change your boot-up settings at the User Guide). Alternatively, you can manually edit the configuration file as follows.

For LILO, you will have to update the file /etc/lilo.conf. This is what a typical lilo.conf looks like, after you have installed your LILO package and before modification:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.2.9-19mdk
        label=linux
        root=/dev/hda1
        read-only
other=/dev/hda2
        label=dos
        table=/dev/hda

Warning

This example assumes that you are using LILO as the main loader! If you are using System Commander, the boot= directive will be different, and you will probably have no other section.

A lilo.conf file consists of a main section, followed by a section for starting each operating system. In the example of the file above, the main section is made up of the following directives:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50

The boot= directive tells LILO where to install its boot sector; in this case, it is the MBR (Master Boot Record) of the first IDE hard disk. If you want to make a LILO floppy disk, you simply replace /dev/hda with /dev/fd0 :-) The prompt directive asks LILO to show the prompt on startup and to start the procedure after 5 seconds (timeout=50). If you remove the directive timeout=, LILO will wait until you have typed something.

Then comes a linux section:

image=/boot/vmlinuz-2.2.9-19mdk
        label=linux
        root=/dev/hda1
        read-only

A linux section always begins with the directive image=, followed by the full path to a valid GNU/Linux kernel. Like any section, it contains a label= directive as a unique identifier. The root= directive tells LILO which partition hosts the root filesystem for this GNU/Linux system. It may be different for you. The read-only directive orders LILO to mount this root filesystem as read-only on startup: if this directive is not there, you will get a warning message.

Then comes the Windows section:

other=/dev/hda2
        label=dos
        table=/dev/hda

In fact, a section beginning with other= is used by LILO to start any operating system other than GNU/Linux: the argument of this directive is the location of this system's boot sector, and in this case it is a Windows system. To find the boot sector, located at the beginning of the partition hosting this other system, GNU/Linux also needs to know the location of the partitions table which will enable it to locate the partition in question, which is done by the table= directive. The label= directive, as with a linux section, identifies the system.

Before adding our linux section, we will kill two birds with one stone :-) Let's compose a message to be displayed on startup before the LILO prompt appears, to explain how to use LILO:

$ cat >/boot/message <<EOF 
> Welcome , this is  LILO (LInux LOader). 
> press the TAB key for a list of boot images .
> You have: 
> * exp : start of Linux-Mandrake  with your new kernel 
> * linux : original Linux-Mandrake  kernel 
> * dos : Windows 
> Pressing ENTER without entering an image name  will start 
> the first image in the list, i.e. exp .
> EOF 
$

And voilą! To display this message at boot up, you simply add the directive:

message=/boot/message

in the main section of lilo.conf. Now, you need to add the GNU/Linux section in order to start with the new kernel. In this example, it will be placed at the top, but nothing prevents you from putting it somewhere else:

image=/boot/vmlinuz-2.2.17
        label=exp
        root=/dev/hda1
        read-only

If you compiled your kernel with the framebuffer, refer to the corresponding paragraph above for GRUB, the difference is now that the option is alone on a new line :

vga=0x315

So this is what our lilo.conf looks like after modification, decorated with a few additional comments (all the lines beginning with #), which will be ignored by LILO:

#
# Main section
#
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
# Our prompt message
message=/boot/message
# Show prompt...
prompt
# ... wait 5 seconds
timeout=50
#
# Our new kernel: default image
#
image=/boot/vmlinuz-2.2.17
        label=exp
        root=/dev/hda1
        read-only
# If the VESA framebuffer is used:
        vga=0x315
#
# The original kernel
#
image=/boot/vmlinuz-2.2.15-19mdk
        label=linux
        root=/dev/hda1
        read-only
#
# Windows Section
#
other=/dev/hda2
        label=dos
        table=/dev/hda

Don't forget to adapt the file to your configuration! The GNU/Linux root filesystem here is /dev/hda1 but it may well be somewhere else on your system, and the same thing applies for Windows. Now that the file has been modified appropriately, you must tell LILO to change the boot sector:

$ lilo 
Added exp *
Added linux
Added dos
$

In this way, you can compile as many kernels as you want, by adding as many GNU/Linux sections as necessary. All you need to do now is restart to test your new kernel.

Notes

[1]

8 bits means 28 colors, i.e. 256; 16 bits means 216 colors, i.e. 64k, i.e. 65536; in 24 bits as in 32 bits, color is coded on 24 bits, i.e. 224 possible colors, in other words exactly 16M, or a bit more than 16 million.


Tux on Star from MandrakeSoft Linux is a registered trademark of Linus Torvalds. All other trademarks and copyrights are the property of their respective owners.
Unless otherwise stated, all the content of these pages and all images are Copyright MandrakeSoft S.A. and MandrakeSoft Inc. 2000.
http://www.linux-mandrake.com/