MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

*DocIndex - Installation

Kernel Upgrade III - Source

* Kernel Configuration
* Kernel Compilation And Installation
* System Configuration
* Configuring LiLo
* Configuring GNU GRUB

Related Resources:

MdkReference, 14
The Linux Kernel HOWTO
KernelTrap
Jeffrey Borg: Compiling a New Kernel

Revision / Modified: Sep. 18, 2001 / Oct. 15, 2001
Author: Tom Berger

 

* Kernel Configuration

(You have read the page about preparations, haven't you?)

If you are compiling the original source archive from kernel.org, you are advised to leave '/usr/src/linux' alone and place and compile the sources somewhere in your home directory tree (which sports the added benefit of only needing to be 'root' during the installation phase).

Run tar xfzC [kernel-source].tar.gz. This will unpack the source archive to a 'linux' subdirectory.

If you have already built a kernel from these sources, run make mrproper to remove old cruft from previous builds. Notice that 'mrproper' also deletes previous '.config' files, so you might want to back up them first.

The kernel configuration takes place in the new 'linux' directory. Basically, there are two ways to accomplish it, a short one by editing the '.config' file and a long one by using one of the provided configuration tools.

The first approach works by editing a copy of M's default kernel configuration file '/usr/src/linux-[...]/arch/[i386|ppc]/defconfig'. It is especially suited for situations where you just want to change a few options and you know what you are doing.
Copy the 'defconfig' file to your current working directory and rename it to '.config'. If you already have a '.config' file from previous builds, you can of course use that one instead, though you might want to create an backup of this file first.
You'll find three types of entries in this file, corresponding to three states possible for many entries (but not all!): 'build into the kernel', 'build as a kernel module' and 'not included':

  • [OPTION]=y
  • [OPTION]=m
  • # [OPTION] is not set

So, to change an option from 'build as a module' to 'build into the kernel' you'd have to change the line

[OPTION]=m

to

[OPTION]=y

You'll find help on most options in the file 'linux/Documentation/Configure.help'.
Edit and save and proceed to the next chapter.

The second way uses one of the supplied kernel configuration interfaces. Being in the 'linux' directory, either issue make config (old style console), or make menuconfig (also console but in much more convenient menu style) or make xconfig (fancy X menu, but heavier on system resources).

Some advice about choosing a good configuration:

  • Read the supplied online documentation.
  • Be careful with including experimental stuff. It is experimental, they are not kidding.
  • Modularize. The smaller the kernel the better, but make sure you don't accidentally throw out something you need at boot time. The available online help will give you tips on what to do.
  • If you're not sure, don't change it. Interdependencies are sometimes delicate and hard to grasp. Better a kernel that is some kilobyte larger than strictly necessary than one that doesn't work at all.

* section index * top

* Kernel Compilation And Installation

Next save your new configuration. Edit the 'Makefile' in your editor of choice and edit the value for 'EXTRAVERSION' to your liking (otherwise you might end up with two different kernels having the same name).

Run

make dep && make clean && make bzImage && make modules

Compile time depends on system and kernel configuration, of course. On most machines, compilation will take between 15 and 45 minutes (that's a wild guess).
If the compilation finished successfully, su to the 'root' account and install the kernel and its modules:

make modules_install && make install

The last command will call the '/sbin/installkernel' script - via 'linux/arch/i386/boot/install.sh' - which will in turn use scripts in '/usr/share/loader' to:

  1. install the kernel to '/boot/vmlinuz-[Version]',
  2. generate an initrd image in '/boot' if necessary,
  3. add entries for the new kernel to '/etc/lilo.conf', '/boot/grub/menu.lst' or '/etc/yaboot.conf' (on PPC machines).

* section index * top

* System Configuration

If everything went fine, you should have two new files in '/boot': 'System.map-[new version]' and 'vmlinuz-[new version]'.
Check if there are files called 'System.map', 'vmlinuz' and (in older Mandrake releases) 'modules.info' in '/boot'. These 'files' are actually links. There are two things you can do with them:

  1. Leave them in place and trust M's init script to sort things out, i.e. to change these symlinks according to the kernel you are booting.
  2. Delete them and change your boot loader config file to reflect the exact kernel versions you are booting.

If you need SCSI devices at boot time (e.g. a SCSI hard disk) and you have SCSI support compiled as a module, the 'installkernel' script should have created a new initrd image in '/boot' and added appropriate entries to the configuration file of your boot loader.
If you rather want to create an image by hand, you can do that withmkinitrd /boot/[name of image] [new kernel version]. You can choose an arbitrary name for the image, as long as it is different from already existing ones. You then have to tell either LiLo or GNU GRUB about this image.

* section index * top

* Configuring LiLo

The 'installkernel' script will autodetect your boot loader and adjust their configuration files accordingly. If you are interested in how to do that by hand anyway, here's the scoop:

Configuring LiLo is done by editing '/etc/lilo.conf', either by loading the file into an editor or (since 7.1) by using the 'DrakBoot' tool in the 'Mandrake Control Center' (aka 'DrakConf'). First change the entry for your old kernel:

  • change image=/boot/vmlinuz to the full name of the (old) kernel image. This is only necessary if you've deleted the 'vmlinuz' link in '/boot'.

  • change label=linux to something like label=linold. This will allow you to boot the old kernel by typing linold at the boot prompt.

Then add an entry for the new kernel at the bottom of the file:

image=/boot/vmlinuz-[new kernel version]
label=linux
root=/dev/[root partition]
initrd=/boot/[initrd image]
readonly

The 'root partition' is the same as for the old kernel. Thelabel=linux entry will boot the new kernel by default.
You only need initrd="/boot/[initrd image]", if your GNU/Linux system resides on a SCSI disk and SCSI support is compiled as a module. If this is the case it is absolutely necessary that you create anew 'initrd' image with

mkinitrd /boot/[initrd image] [new kernel version]

The only requirement for the name of the new initrd images is that it differs from the old one. Then point the initrd entry of the new kernel in '/etc/lilo.conf' to this new image.

Run lilo. Don't forget this! If you get no error messages, it is safe to reboot.

* section index * top

* Configuring GNU GRUB

If you are using the GNU GRUB boot loader, add an entry to '/boot/menu.lst' (or use 'DrakBoot' in the 'Mandrake Control Center') like this:

title [menu entry]
kernel (hd[x],[y])/boot/[kernel] root=/dev/[z]

title specifies the entry under which the new kernel will appear in the boot menu. 'x' and 'y' tell GNU GRUB where '/boot', which holds the kernel image, is located: 'x' denotes the number of the hard disk (regardless of it being an IDE or an SCSI disk) starting from '0', 'y' the number of the partition, also starting from '0'. So, (hd0,0) tells GNU GRUB: "look for the first partition on the first hard disk in the boot chain". Once it has found this partition, GNU GRUB needs to know the location and name of the kernel image, e.g./boot/mynewkernel.
Since 'init', the initial GNU/Linux boot process, also needs to know on which partition the kernel is, you need to tell it this in its own parlorroot=/dev/hda1. If you've created a ramdisk image, addinitrd /boot/[name of initrd image] and also any other kernel parameters you might need or prefer.
Note that if '/boot' is on the first logical partition of a drive (/dev/hda5), the entry has to read (hd0,4), regardless of the number of primary partitions on the disk.

By changing the number in the default field (or marking the field in 'DrakBoot'), you can tell GNU GRUB to boot the entry by default. Note again that GNU GRUB starts counting from '0', so to start the second entry in '/boot/grub/menu.lst', you have to change the number to '1'.

Having made your changes, save the file and reboot.

* section index * top

* Troubleshooting

 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.