The kernel is located in arch/i386/boot/bzImage (or zImage if you chose 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.22-foo. The sequence of commands you will have to type is:
$ cp arch/i386/boot/bzImage /boot/vmlinux-2.4.22-foo $ cp System.map /boot/System.map-2.4.22-foo |
Now you need to tell the boot loader about your new kernel. There are two possibilities: GRUB or LILO. Note that Mandrake Linux is configured with LILO by default.
The simplest way of updating LILO is to use drakboot (see chapter Change Your Boot-up Configuration in the Starter 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.20-17mdk label=linux root=/dev/hda1 read-only append="devfs=mount" vga=788 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 start-up. 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.
image=/boot/vmlinuz-2.4.20-17mdk label=linux root=/dev/hda1 read-only append="devfs=mount" vga=788 |
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 file system for this kernel. It may be different in your configuration... The read-only directive tells LILO that it should mount the root file system as read-only on start-up: if this directive is not there, you will get a warning message. The append line specifies options to pass to the kernel. Finally the vga parameter configures the framebuffer.
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 partition table which will enable it to locate the partition in question. This is done through 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 don't enclose it within another section. Here is what it can look like:
image=/boot/vmlinux-2.4.22-foo label=foo root=/dev/hda1 read-only |
Of course, adapt it to your configuration! We took a different situation on purpose (not the same as the GRUB one showed above...)
If you compiled your kernel with the framebuffer, refer to the corresponding paragraph above concerning GRUB. The only difference 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.22-foo label=foo root=/dev/hda1 read-only # If the VESA framebuffer is used: vga=0x315 # # The original kernel # image=/boot/vmlinuz-2.4.20-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 your machine to test your new kernel. Notice that if LILO shows any error during installation, it means that it has changed nothing. LILO only modifies your configuration if it finds no error in the process.
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 Starter Guide). Alternatively, you can manually edit the configuration file as follows.
You need to edit the /boot/grub/menu.lst file. 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 are 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.
The linux section starts by telling GRUB about the kernel which is to be loaded (kernel hd(0,4)/boot/vmlinuz), followed by the options to pass to the kernel. In this case, root=/dev/hda5 will tell the kernel that the root file system is located on /dev/hda5. In fact, /dev/hda5 is the equivalent of GRUB's hd(0,4), but nothing prevents the kernel from being on a different partition than the one containing the root file system;
the failsafe section is very similar to the previous one, except that we will pass an argument to the kernel (failsafe) which tells it to enter “single” or “rescue” mode;
the windows section tells GRUB to simply load the first partition's boot sector, which probably contains a Windows boot sector;
the floppy section simply boots your system from the floppy disk in the first drive, whatever the system installed on it. It can be a Windows bootdisk, or even a GNU/Linux kernel on a floppy;
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.22-foo root=/dev/hda5 |
Don't forget to adapt the file to your configuration! The GNU/Linux root file system here is /dev/hda5, but it can 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 /usr/src/linux/Documentation/fb/vesafb.txt file (only in the case of the VESA framebuffer! Otherwise, refer to the corresponding file). For the 800x600 mode in 32 bits[35], the mode number is 0x315, so you need to add the directive:
vga=0x315 |
title foo kernel (hd0,4)/boot/vmlinux-2.4.22-foo root=/dev/hda5 vga=0x315 |
For more information, please consult the info pages about GRUB (info grub).
[35] 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.