16.6. Installing the new kernel

The kernel is located in arch/i386/boot/bzImage (or zImage if you have chosen to make zImage instead). The standard directory in which kernels are installed is /boot. You also need to copy the System.map file to ensure that some programs (top is just one example) will work correctly. Good practice again: name these files after the kernel version. Let us assume that your kernel version is 2.4.10-foo. The sequence of commands you will have to type is:

$ cp arch/i386/boot/bzImage /boot/vmlinux-2.4.10-foo
$ cp System.map /boot/System.map-2.4.10-foo

Now you need to tell the bootloader about your new kernel. There are two possibilities: grub or LILO. Note that Mandrake Linux is configured with LILO by default.

16.6.1. Updating grub

Obviously, retain the possibility of starting your current kernel! The simplest way of updating grub is to use drakboot (see chapter Change your boot-up configuration in the User Guide). Alternatively, you can manually edit the configuration file as follows.

You need to edit the file /boot/grub/menu.lst. This is what a typical menu.lst looks like, after you have installed your Mandrake Linux 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 images, each one corresponding to a different GNU/Linux kernel or another OS. timeout 5 defines the time (in seconds) for which grub will wait for input before it loads the default image (this is defined by the default 0 directive in common options, i.e. the first image in this case). The keytable directive, if present, defines where to find the keymap for your keyboard. In this example, this is a French layout. If none is present, the keyboard is assumed to be a plain qwerty keyboard. All hd(x,y) which you can see refer to partition number y on disk number x as seen by the BIOS.

Then come the different images. In this example, four images are defined: linux, failsafe, windows, and floppy.

Note

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

Now to the point. We need to add another section to tell grub about our new kernel. In this example, it will be placed before the other entries, but nothing prevents you from putting it somewhere else:

title foo
kernel (hd0,4)/boot/vmlinux-2.4.10-foo 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.

And that's it. Unlike LILO, as we will see below, there is nothing else to do. just restart your computer and the new entry you just defined will appear. Just select it from the menu and your new kernel will boot.

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 foo
kernel (hd0,4)/boot/vmlinux-2.4.10-foo root=/dev/hda5 vga=0x315 

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

16.6.2. Updating LILO

The simplest way of updating LILO is to use drakboot (see chapter Change your boot-up configuration in the User Guide). Alternatively, you can manually edit the configuration file as follows.

The LILO configuration file is /etc/lilo.conf. This is what a typical lilo.conf looks like:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
vga=normal
default=linux
keytable=/boot/fr-latin1.klt
lba32
prompt
timeout=50
message=/boot/message
image=/boot/vmlinuz-2.4.8-17mdk
        label=linux
        root=/dev/hda1
        read-only
other=/dev/hda2
        label=dos
        table=/dev/hda 

A lilo.conf file consists of a main section, followed by a section for 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
vga=normal
default=linux
keytable=/boot/fr-latin1.klt
lba32
prompt
timeout=50
message=/boot/message

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, simply replace /dev/hda with /dev/fd0. The prompt directive asks LILO to show the menu on startup. As a timeout is set, LILO will start the default image after 5 seconds (timeout=50). If you remove the timeout directive , LILO will wait until you have typed something.

Then comes a linux section:

image=/boot/vmlinuz-2.4.8-17mdk
        label=linux
        root=/dev/hda1
        read-only

A section to boot a GNU/Linux kernel always starts with an image= directive, followed by the full path to a valid GNU/Linux kernel. Like any section, it contains a label= directive as a unique identifier, here linux. The root= directive tells LILO which partition hosts the root filesystem for this kernel. It may be different in your configuration... The read-only directive tells LILO that it should mount the 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. This is done by the table= directive. The label= directive, as with the linux section above, identifies the section.

Now, it's time we added a section for our new kernel. You can put this section anywhere behind the main section, but not enclose it within another section. Here is what it will look like:

image=/boot/vmlinux-2.4.10-foo
        label=foo
        root=/dev/hda1
        read-only

Of course, adapt it to your configuration! We purposely took a different situation to that in grub above...

If you compiled your kernel with the framebuffer, refer to the corresponding paragraph above for grub, the difference now is 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
# At boot, we want normal VGA. The framebuffer will switch resolutions by
# itself if we use it:
vga=normal
# Our boot message...
message=/boot/message
# What should be booted by default. Let's put our own kernel as the default:
default=foo
# Show prompt...
prompt
# ... wait 5 seconds
timeout=50
#
# Our new kernel: default image
#
image=/boot/vmlinux-2.4.10-foo
        label=foo
        root=/dev/hda1
        read-only
# If the VESA framebuffer is used:
        vga=0x315
#
# The original kernel
#
image=/boot/vmlinuz-2.4.8-17mdk
        label=linux
        root=/dev/hda1
        read-only
#
# Windows Section
#
other=/dev/hda2
        label=dos
        table=/dev/hda
This could well be what your lilo.conf will look like... but remember, again, to adapt it to your own configuration.

Now that the file has been modified appropriately, but unlike grub which does not need it, you must tell LILO to change the boot sector:

$ lilo
Added foo *
Added linux
Added dos
$

In this way, you can compile as many kernels as you want, by adding as many 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. 2001.
http://www.mandrakelinux.com/