Compile And Install A Kernel



It's always a good idea to recompile your kernel. The reason for this is that the default Mandrake kernel is very bloated because it has to be installed on a wide variety of system configurations and hardware scenarios. Re-compiling the kernel will result in a much smaller and faster kernel. 

The following details how I install a kernel.


Getting Started

1) As root, cd to the /usr/src directory, type:

ls -l linux

If you get something like... linux -> linux-2.x.xx then this is a symlink. Delete the /usr/src/linux symlink.

2) To take advantage of Mandrake's Supermount feature, I always recompile the kernel from Mandrake sources. Go to Rpmfind and do a search for kernel-source, download and install the latest Mandrake kernel- source .rpm.

3) Make sure you have the Tk package installed (needed to run xconfig)


Configure The Kernel
 

Cd to /usr/src and type ls, you should now see a directory for the kernel source you just installed. Cd to that directory, then type:

make mrproper

make xconfig

Take your time here. Make sure to include everything that you'll need and remove anything that you don't (modules for superdisk, zip drives, usb support, video card, soundcard etc....) This is a default Mandrake source and it will have support for several sound cards, video cards etc... that you don't need, so if your sure you don't need it, say no.

If you have a dual boot system make sure you choose to enable vfat filesystem support etc...

I always choose [y] for "Code Maturity Level Options" in the very first box under xconfig, this is necessary if you have any hardware that requires experimental drivers. For example, the reiserfs file system is experimental.

Use modules whenever possible, this makes the kernel smaller and faster. I chose [m] for the sound and network options, this will load the sound and network drivers as modules when their needed by the system.

If not sure what to choose, use the help button to the right for more info and recommendations. After reviewing all of your selections, save and exit.
 

Reiserfs

If you're using the Reiserfs file system, the 2.4.X kernel has Reiserfs support built in.

When configuring the kernel, enable reiserfs as [ y ], do not choose to load it as a module. The reiserfs website recommends that you also upgrade Lilo to version 0.21.6 or better.  


Compile The Kernel
 

Next, type:

make dep
make bzImage
make modules
make modules_install

Make bzImage will take the longest, so you may want to take a break and let it do it's thing. Also make sure you type "make bzImage" correctly (capital I).


Kernel Installation

1) Copy your new kernel to your boot directory:

cp /usr/src/linux-2.4.X/arch/i386/boot/bzImage /boot/vmlinuz-2.4.X

2) Copy your new System.map to your boot directory:

cp /usr/src/linux-2.4.X/System.map /boot/System.map-2.4.X
 

You should now have 2 new files in /boot (change 2.4.X to match your kernel number).


Update Lilo
 

Next, you'll need to configure Lilo and add entries for the new kernel, you will still be able to boot to your old kernel as well.

1) Open the /etc/lilo.conf file with a text editor

2) Add the following entry for your new kernel

image=/boot/vmlinuz-2.4.X
label=Linux-2.4.X
root=/dev/hdaX
append=" hdx=ide-scsi devfs=mount quiet"
vga=788
read-only
 

Change root=/dev/hdaX to match whatever your old lilo entries are.

I left out the references to initrd. This is not needed if you compiled the reiserfs option into the kernel. From what I gather, initrd is only needed to load special drivers (modules) for booting the root (/) directory. You would need this if you had a SCSI drive or if you compiled reiserfs support as [m] (module). If you compiled reiserfs as a module, take a look at man initrd for info on creating a initrd.img file for the new kernel in the /boot directory.

The append line is only needed if you have a cdburner.

vga=788 is for frame buffer support, will only work if your video card supports this and is not necessary.


3) Next while still in the console update Lilo by typing:

Lilo

If there are no errors, then reboot to the new 2.4 kernel.
 


Kernel Patches
 

Kernel patches are a way of updating or adding new or special features to your kernel and must be applied before compile time.

Use the following commands to patch the Linux kernel:
 

cd /usr/src/linux
patch -p1 < /path/to/patch