![]() | Note |
---|---|
The procedures in this section apply to the x86 architecture. If you have a different architecture, the files' location and the files to install might be different. |
The kernel is
located in arch/i386/boot/bzImage
. 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.6.10-foo
.
The sequence of commands you will have to type is:
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.8-foo # cp System.map /boot/System.map-2.6.10-foo
Now you need to tell the bootloader about your new kernel. There are two bootloaders: GRUB and LILO. Note that Mandrakelinux is configured with LILO by default.
The simplest way of updating LILO is to use drakboot (see the Change Your Boot-up Configuration chapter 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 default="linux" keytable=/boot/es-latin1.klt prompt nowarn timeout=50 message=/boot/message menu-scheme=wb:bw:wb:bw image=/boot/vmlinuz label="linux" root=/dev/hda1 initrd=/boot/initrd.img append="devfs=mount resume=/dev/hda5" read-only other=/dev/fd0 label="floppy" unsafe
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 default="linux" keytable=/boot/es-latin1.klt prompt nowarn timeout=50 message=/boot/message menu-scheme=wb:bw:wb:bw
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 label="linux" root=/dev/hda1 initrd=/boot/initrd.img append="devfs=mount resume=/dev/hda5" 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
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 during booting.
Then comes the floppy section:
other=/dev/fd0 label="floppy" unsafe
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 to boot from a floppy disk.
Now, it's time to add a section for our new kernel. You can put this section anywhere after the main section, but do not enclose it within another section. Here is what it should look like:
image=/boot/vmlinuz-2.6.10-foo label="foo" root=/dev/hda1 read-only append="devfs=mount resume=/dev/hda5"
Needless to say: adapt the entry to your system's configuration.
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 message=/boot/message # What should be booted by default. Lets put our own new kernel: default="foo" # Show prompt... prompt # ... wait 5 seconds timeout=50 # # Our new kernel: default image # image=/boot/vmlinuz-2.6.10-foo label="foo" root=/dev/hda1 read-only append="devfs=mount resume=/dev/hda5" # # The original kernel # image=/boot/vmlinuz label="linux" root=/dev/hda1 read-only append="devfs=mount resume=/dev/hda5" # # Floppy Section # other=/dev/floppy label="floppy" unsafe
This could
well be what your lilo.conf
will look like... but
remember, again, 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 floppy #
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. Note that if LILO finds and displays errors during installation, it does not modify your boot sector configuration. LILO only modifies your configuration if there are no errors found in the process.
Obviously, retain the option of starting your current kernel! The simplest way of updating GRUB is to use drakboot (see the Change Your Boot-up Configuration chapter 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
Mandrakelinux 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 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 of the
hd(x,y)
which you see refer to partition
number y
on disk number x
as seen by the BIOS. Note that the countdown starts at
zero!
Then
come the different images. In this example, three images are
defined: linux
, failsafe
,
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 to 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
floppy
section simply boots your system from the
floppy disk in the first floppy drive, whatever the system installed
on it. It can be a Windows® boot disk, or even a
GNU/Linux kernel on a 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/vmlinuz-2.6.10-foo root=/dev/hda5
Do not 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 your newly defined entry will just 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
(but only in the case of the VESA framebuffer! Otherwise, refer to
the corresponding file). For the 800x600 mode in 32 bits[40], the mode number is 0x315
, so you need
to add the directive:
vga=0x315
title foo kernel (hd0,4)/boot/vmlinuz-2.6.8-foo root=/dev/hda5 vga=0x315
For more information, please refer to the info pages about GRUB (info grub).
[40] 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.