HOWTO: Kernel Recompiling

Permabanned
Joined
18 Oct 2002
Posts
2,010
Location
Huddersfield / Antartica
HOW-TO: Kernel Recompiling

HOW-TO: Kernel Recompiling

When it comes to recompiling a kernel, a lot of new Linux users chicken out, there are a few guides on the net, but none of them are very newbie friendly. So, here is my HOWTO on Kernel compiling.

First cd to the kernel sources directory, this is usually /usr/src/linux but can be any directory under /usr/src/
For example my current directory is at: /usr/src/linux-2.4.19-gentoo-r7/[/i], but yours will most likely be at /usr/src/linux.

If you dont have any of these directorys then you can download the latest stable kernel (2.4.18) from kernel.org The download is 29045KB, so it is relatively large.

Download this to your home directory, (/home/usrname/).

Now. su to root:



Code:
sh-2.05a$ su
Password: <insert root password here>


And then cd to /usr/src/ and untar the file here:


Code:
bash-2.05a# tar xvzf /path/to/linux-2.4.18.tar.gz


You will now see the file untar to /usr/src/linux, cd into this directory:


Code:
bash-2.05a# cd linux


Now you have 3 options:

  • make menuconfig - where you are presented with a menu of the different kernel options
  • make xconfig - where you get an X dialog to choose the different options you would like
  • make config - where each option is presented one by one



I recommend menuconfig. Pressing ? while on an option will give you help and pressing <space> will select it. EIther a * or a M will appear in the box next to it, the <M> denotes it will be compiled as a module and the <*> represents it will be included in the kernel. Make sure you choose that you can have modules, and make sure you include everything you need. In this case ? is your best friend!

When completed exit the config utils, ensuring that you opt to save the config files...

Then, still as root and in /usr/src/linux or your kernel directory type

Code:
bash-2.05a# make dep && make clean bzImage modules


Then sit back and relax as the kernel compiles

Then copy the bzImage you have just made to the /boot partition, I have also included a mv command so that the previous bzImage is moved to bzImage.orig


Code:
# mv /boot/bzImage /boot/bzImage.orig [if bzImage already exists]
# cp /usr/src/linux/arch/i386/boot/bzImage /boot


Now update your bootloader, for GRUB this would be in menu.lst. cd to /boot/grub and edit menu.lst and add:


Code:
title=<kernel name>
root (hd0,0) <this would be my primary master the privary slave is (0,1) and the secondary master is (1,0) and so on> 
kernel /boot/bzImage <this is the path to the bzImage of the kernel> root=/dev/hda3 <and where the  / linux partition is>


I dont use LILO so I cant tell you how to configure that but there are plenty of HOWTOs on that.

Hope this helps
Shak
 
Back
Top Bottom