Linux-Mandrake: |
User Guide and |
Reference Manual |
MandrakeSoft
January 2000 http://www.linux-mandrake.com
Along with filesystem mounting and source compilation, this is undoubtedly the subject which causes the most problems for beginners. Compiling a new kernel is not generally necessary, since the kernels installed by Linux-Mandrake contain support for a significant number of devices, but...
It may be, why not, that you want to do it, for no other reason than to see "what it does". Apart from making your PC and your coffee machine work a bit harder than usual, not a lot. However, the aim of this chapter is that your coffee machine should still work after compilation.
There are also valid reasons. For example, you have read that the kernel you are using has a security bug, a bug which is corrected in a more recent version; or else, a new kernel includes support for a device you need. You have the choice of waiting for upgrades or else compiling a new kernel yourself, and opt for the second solution.
Whatever you do, stock up with coffee.
The main kernel source host site is ftp.kernel.org
, but it has a
large number of mirrors, all named ftp.xx.kernel.org
, where
xx
represents the country's ISO code. Following the
official announcement of the availability of the kernel, you should
allow two hours for all the mirrors to be supplied.
On all these FTP servers, the sources are in the directory
/pub/linux/kernel
. Next, go to the directory with the series
that interests you: it will undoubtedly be v2.2
. There is
nothing to prevent you trying version 2.3 kernels, but remember that
these are experimental kernels. The file containing the kernel sources
is called linux-<kernel.version>.tar.gz
, e.g.
linux-2.2.11.tar.gz
.
There are also patches for application to kernel sources to upgrade it
incrementally: thus, if you already have kernel sources version 2.2.11
and want to update to kernel 2.2.13, you do not need to download all the
sources, but can simply download the patches
patch-2.2.12.gz
and patch-2.2.13.gz
. As a general rule,
this is a good idea, since sources currently take up more than 12
MB.
Kernel sources should be placed in /usr/src
. So you should go
into this directory then unpack the sources there:
$ cd /usr/src
$ mv linux linux.old
$ tar xzf /path/to/linux-2.2.11.tar.gz
The command mv linux linux.old
is required: this is because
you may already have sources of another version of the kernel. This
command will ensure that you do not overwrite them. Once the archive is
unpacked, you have a linux
directory with the sources of the new
kernel.
Now, the patches. We will assume that you do want to patch from
version 2.2.11 to 2.2.13 and have downloaded the patches needed to do
this: go to the newly created linux
directory, then apply the
patches:
$ cd linux
$ gzip -dc /path/to/patch-2.2.12.gz | patch -p1 #
$ gzip -dc /path/to/patch-2.2.13.gz | patch -p1
$ cd ..
Generally speaking, moving from a version 2.2.x to a version 2.2.y
requires you to apply all the patches numbered 2.2.x+1, 2.2.x+2, ...,
2.2.y in order . To "descend" from 2.2.y to 2.2.x, repeat
exactly the same procedure but applying the patches in reverse order and
with option -R
from patch
(R
stands for
Reverse). So, to go back from kernel 2.2.13 to kernel 2.2.11,
you would do:
$ gzip -dc /path/to/patch-2.2.13.gz | patch -p1 -R
$ gzip -dc /path/to/patch-2.2.12.gz | patch -p1 -R
Next, for the sake of cleanness (and so that you know where you are),
you can rename linux
to reflect the kernel version and create a
symbolic link:
$ mv linux linux-2.2.11
$ ln -s linux-2.2.11 linux
It is now time to move on to configuration. For this you have to be in the source directory:
$ cd linux
To configure the kernel you have the choice between:
make xconfig
for a graphical interface,
make menuconfig
for an interface based on
ncurses
, or
make config
for the most rudimentary interface, line by
line, section by section.We will go through configuration section by section, but you can skip
sections and jump to the ones that interest you if you are using
menuconfig
or xconfig
. The choice for options is
'y'
for Yes (functionality hard compiled into the
kernel), 'm'
for Module (functionality compiled as a
module), or 'n'
for No (do not include in the
kernel).
For xconfig
, you will have guessed what the
Main Menu, Next and
Prev buttons are for. For menuconfig
, use
the Enter
key to select a section, and change options with
'y'
, 'm'
or 'n'
to change its status or else press the
Enter
key and make your choice for the multiple choice options.
Exit will take you out of a section and out of
configuration if you are in the main menu. And obviously, there is
Help.
So here is a somewhat rough list of the options and the choices recommended for those options, gilded with explanations when necessary. The options not covered here are left to your discretion. Leaving them "as is" is generally a good idea.
'y'
PPro/6x86MX
if your
processor is an Intel Pentium Pro,
Pentium II, Celeron or above, or a Cyrix 6x86 or
\techCHARACTERUNDERSCOREcyrixCHARACTERUNDERSCOREmii.
'n'
'y'
. Even if your processor does not support them, it does not
matter.
'y'
only if your machine is multi-processor!
'y'
'n'
'y'
'y'
-- even
if you are not on a network! You will at least need it for
loopback interface.
'y'
-- unless you
have no PCI bus on your machine.
'y'
'y'
'n'
-- unless you
have this kind of bus (e.g. IBM PS/2 machines).
'n'
-- or else you must be filthy rich!
'y'
'y'
'y'
'm'
'y'
'm'
'y'
or 'm'
,
your choice.
'y'
only if you answered 'y'
to the Parallel port
support option. Otherwise, you must answer 'm'
and add the line
alias parport_lowlevel parport_pc
to the configuration file
/etc/conf.modules
.
'n'
'y'
, if your motherboard supports it.
'n'
'n'
'n'
'y'
'y'
'y'
'y'
'n'
if your PC
is on local time, 'y'
if it is on GMT.
'n'
(but read help!)
'y'
-- but
you should realize that all this option does is question the
BIOS PNP on the configuration of the PNP boards if there
are any (remember that PNP has no sense for PCI devices).
'm'
si
if you have parallel port devices, otherwise 'n'
'm'
'y'
'n'
'y'
. If you have IDE disks but start on
a SCSI disk, you can answer 'm'
'm'
if
you have an IDE CDROM drive.
'y'
or
'm'
'y'
or 'm'
if you have, for example, an IDE ZIP drive.
'm'
if you
have an IDE writer, otherwise 'n'
'y'
'y'
'n'
'y'
'm'
'n'
'n'
-- unless you want to try out RAID. If so, see
RAID-HOWTO
.
'n'
'n'
-- what,
you still have disks like this? :)
'm'
if
you have this sort of devices, 'n'
otherwise. If you answer 'm'
,
you will then need to select what types of devices you want to support
and what protocols. Refer to kernel help to find out more. There are no
generic solutions on this point, except to compile everything into
modules:)
'm'
'y'
'n'
'm'
'n'
, unless you want
to do IP masquerading (several machines behind one Internet
connection) or else simply a firewall, in which case you should answer
'y'
.
'y'
--
otherwise X will not work.
'y'
'n'
'y'
here it means you know what you are doing -- otherwise, answer
'n'
'y'
, otherwise 'n'
. For
masquerading, you will also need to answer 'y'
to
IP: always defragment (required for masquerading),
IP: masquerading and IP: ICMP
masquerading
'n'
,
unless the machine is actually a dedicated router.
'y'
if you are
on a network -- see also help on this subject.
'y'
'n'
, unless you are connected via a very high throughput interface
(gigabit Ethernet, FDDI, etc.)
'y'
if you have one (or
more) SCSI adapter(s) and device(s), a parallel port ZIP drive or
an IDE writer, 'n'
otherwise. Choose 'y'
for
SCSI disk support if you boot on a SCSI
disk, and not 'm'
! Also say 'm'
to SCSI
generic support if you have a CD writer (SCSI or IDE), and
answer appropriately for other types of device. When the moment comes
to determine what your SCSI adaptor(s) is (are), refer to file
/etc/conf.modules
: Linux-Mandrake installation will have
established which drivers to use.
'n'
'n'
'n'
'm'
only if you have an old generation ZIP!
'm'
here.
'y'
if you have a
network device, or if you want to connect to the Internet by
modem, 'n'
otherwise.
'm'
'y'
if you have
one or more Ethernet cards. Then select the appropriate
driver(s) for your Ethernet card(s).
'y'
or
'm'
if you want to connect to the Internet via a modem.
'n'
'y'
or 'm'
if
you have infrared devices on your PC. If so, answer 'y'
or
'm'
to the different options proposed: IrLAN
protocol if you have an infrared transmitter/receiver to communicate
with other PCs with a similar interface (Ethernet emulation),
IrCOMM protocol if you have an infrared device
emulating a serial port, IrLPT protocol for
infrared devices emulating a parallel port. Say 'y'
to
IrDA protocol options, 'y'
to
Cache last LSAP, 'n'
to
Fast RRs (but see help on this subject), 'n'
to
Debug information, 'n'
to
IrLAP compression unless you want to try it (see
help), 'y'
or 'm'
to IrTTY (uses Linux
serial driver) and IrPORT (IrDA serial driver);
then comes the support for the different infrared chips, choose the ones
you have (refer to the documentation on your hardware).
'y'
if you have an
internal ISDN adapter. If you connect to the
Internet using this type of connection, also answer 'y'
to
Support synchronous PPP. You will have to ask your
Internet Service Provider if it supports Van
Jacobson compression to answer appropriately the option
Use VJ-compression with synchronous PPP. Answer
'n'
to Support generic MP (RFC 1717) (but see
help), 'n'
to Support audio via ISDN
(but see help) and to Support ISDN diversion
services. Then comes the choice of driver for your ISDN card: refer
to your hardware documentation.
'n'
, unless you have a CDROM driver with a proprietary interface.
Very rare these days.
'y'
'y'
'y'
'n'
'n'
'n'
'y'
-- leave
the option Maximum number of Unix98 PTYs in use
(0-2048) at its default value, 256.
'm'
if you have
a parallel port printer. In this case, also say 'y'
to
Support IEEE1284 status readback.
'y'
here,
then 'y'
or 'm'
to the appropriate mouse type. Refer to help for
each of these options. As indicated in help, for any type of strange
mouse which is neither serial, nor PS/2, refer to
Busmouse-HOWTO
. In particular, be careful with laptops.
'y'
if you have this
type of non SCSI tape drive.
'n'
'n'
'y'
'y'
. Then answer 'y'
or
'm'
, as preferred, to the options that apply to your device. Here
again, your hardware documentation will be useful.
'y'
or 'm'
if you
have a joystick and want to use it. Then you must choose the driver
which matches your joystick. Refer to help and your hardware
documentation.
'y'
if you
have a tape drive connected to the floppy disk controller. Then refer to
help for the different options.
'n'
-- if you
answer 'y'
here, it means you know what you're talking about
:)
'n'
'y'
or 'm'
,
unless you have no desire at all to access MS-DOS/Windows floppy
disks or partitions from Linux.
'm'
'n'
'm'
-- includes FAT32 support.
'm'
'y'
'y'
'y'
'y'
'y'
if your
machine is an NFS client. Otherwise, 'n'
.
'y'
if your machine
is to act as an NFS server.
'y'
if you want to mount partitions from a file server
running Windows (9x or NT), otherwise 'n'
.
This option is not necessary if you are making an SMB
server.
'm'
'm'
'm'
'm'
'y'
'y'
. The framebuffer gives
you virtual consoles which are much more eye candy as well as a pretty
logo on startup :)
However, it does not prevent you using a
X server. Say 'y'
also to Support for
frame buffer devices (EXPERIMENTAL), 'y'
to
VESA VGA graphics console.
'm'
here if you
have a sound card, and refer to your /etc/conf.modules
to find
out which driver to use. This assumes that you have already configured
your sound card, with sndconfig
.
'n'
And voilą! Configuration is finally over. Save your configuration and quit.
The configuration file is /usr/src/linux/.config
. In general, it
is a very good idea to make a backup copy! Preferably, put this copy in
the personal directory of user root
. As the configuration
changes very little between kernel revisions (i.e. between two versions
2.2.x or 2.3.x or... kernels), you can use it again to configure your
future kernels.
Next, time for compilation.
Small point to begin with: if you are recompiling a kernel with exactly
the same version as the one already present on your system, the latter's
modules must be deleted first. For example, if you are recompiling
2.2.10, you must delete directory /lib/modules/2.2.10
.
Compiling the kernel and modules, and installing the modules is done in a single line:
$ make dep && make bzImage && make modules &&
make modules_install
If you are asking what this famous &&
is for, here is the
explanation: a && b
first runs a
, and runs
b
if and only if a
was completed
successfully. By extension, you can imagine what the above command line
does: if one of the commands fails, the subsequent commands will not be
run. Another thing that failure means is that there is a bug in the
kernel! If that happens, tell us...
One more thing: no, compiling a new kernel will not invalidate the old
one! If compilation fails here, it does not mean that your system will
no longer start. To prevent your system from booting, you have to do
something really stupid -- which, honestly, will not happen if
you follow the instructions in this chapter to the letter :)
With your kernel now successfully compiled, all you need to do now is install it. Again for the sake of cleanness 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.13 kernel. Here, the types of commands are as follows:
$ cp arch/i386/boot/bzImage /boot/vmlinuz-2.2.13
$ cp System.map /boot/System.map-2.2.13
After this, you still have to update the file /etc/lilo.conf
.
Obviously, retain the possibility of starting your current kernel! This
is what a typical lilo.conf
looks like, after you have installed
your Linux-Mandrake distribution 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 exemple assumes that you are using LILO as the main loader! If you are using System Commander, theboot=
directive will be different, and you will probably have noother
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 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 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:
image=/boot/vmlinuz-2.2.9-19mdk
label=linux
root=/dev/hda1
read-only
In fact, a section beginning with other=
is used by
LILO to start any operating system other than 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, 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
Linux section in order to start on the new kernel. In this
example, it will be placed at the top, but nothing prevents you putting
it somewhere else:
image=/boot/vmlinuz-2.2.13
label=exp
root=/dev/hda1
read-only
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 section
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[22], the mode number is 0x315
, so you need to
add the directive:
vga=0x315
to our new LILO section. 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.13
label=exp
root=/dev/hda1
read-only
# If the VESA framebuffer is used:
vga=0x315
#
# The original kernel
#
image=/boot/vmlinuz-2.2.9-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 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 Linux sections as necessary. All you need to do now is restart to test your new kernel.