Created July 4, 2004
(Transferred from Wiki by Peter)
This PET describes compiling you own 2.6.x kernel. The method of compling the kernel is similar as in previous kernels but there are a few distint differnces. This has been tested on Fedora Core 2, but should work for most distributions.
The one thing I dreaded while in linux was compiling my kernel - it just sounds spooky. After all the kernel controls everything in a linux system. overcoming this fear was for me about 90% of the battle. I read the kernel compiling how-to many times before i tried it. Here is how finally got around to doing it. This is a pretty typical desktop configuration I think. There are no SCSI devices in my system and all I do is what every body does with thier linux boxes - enjoy stable and excellent applciaitons. You should do all of these steps as root excecpt for downloading from the internet. Please don't go on the internet as root. Also make sure there is a compiler installed on your system. This can be gcc or egcs, possibly others. Personally I have yet to have a problem with gcc and gcc just rolls off the tounge so nicely.
What you need to have installed to compile your own kernel, also known as dependecnies:
gcc - the compiler, this comes with the development tools. 'make - a tool to give instructions to the compililer. qt - needed only if using make xconfig to configure the kernel. This comes with KDE, but KDE is not needed, only qt. gtk - needed only if using make gconfig to configure the kernel. This comes with GNOME. ncurses - needed only if using make menuconfig to configure the kernel. mkinitrd - needed to create an image for loading drivers durring boot process. This also has scripts for installing the kernel.
The really short version!!
make mrproper, this cleans up all old generated files and the configuration. make xconfig or make menuconfig or make gconfig select what you want for your system. This is far and away the most important step of the process. My config is here: make - this compiles all binaries. make install - This will copy the files, modules, create the bootdisk image and even edit the bootloader configuration so it will be on the boot menu next time the machine is booted. User root needs to run this command from the directoty where the kernel was compiled.
The not so short but more detailed verison!!
- Know what hardware you have and what other things you may wish to do. This can include CD burning, listening to music, having a firewall to keep the pesky script kiddies out, surfing the web, watching DVDs and who knows what else.
- Okay here is where we do something with the computer!! Find out if everything you want is supported in the current kernel at www.kernel.org. This will make it such that you do not need apply a patch. Before you run off and scream what the h*ll is a patch?? let me tell you that odds are very good you will not need to apply one. Linus, Alan and the rest kernel development people do a great job at making sure we don't need to worry too much about extra stuff like that. It is nice to know patches are there if needed though. Download the kernel, at the time of this writing the current kernel is 2.6.7. Netscape, Mozilla or gftp work great for this. If you do need to apply a patch a quick method to do so is listed at the end of this document.
- Now look in the directory /usr/src - if you have a directory called linux already there then now would be a good time to rename it or delete it. e.g. to rename it type mv linux old_linux or to remove it type rm -rf linux. Next, copy the downloaded kernel to the directory /usr/src/ .i.e. cp linux.2.6.7.tar.gz /usr/src/. and untar it. If you have downloaded the bzip version the name may end with a .tar.bz2. If you have the bzip version type tar -jxf linux.2.6.7.tar.bz2, if you have the gnuzip version type tar -zxvf linux.2.6.7.tar.gz. There is now a new directory called linux.
- Now cd into the linux directory. Type ls -a to list all files. If there is a file called .config you can save this to another directory with a meaningingful name (/boot/config-kernelversion is a good choice). This is the file that determines how the kernel was getting configured.
- make mrproper, this cleans up all old generated files and the configuration.
This configuration has support for the following options:
* Athlon Processor
* Sound Blaster Live Support
* VIA Ethernet Adaptor support
* IDE-CD Writer support
* USB support for generic USB joy sticks
* USB mouse support
* ext3 kernel support
* vfat (fat32) support
* NFS (Network File System) support
* Power Management Support
* IP Tables
* IDE hard drive support for VIA and Silicon Image SATA controlles.
* Paralell port port for printers
Here is a config for an NVIDIA Chip set with a SMP kernel for an Athlon 64 processor. http://home.comcast.net/~pbharris/files/188.8.131.52_config2
If you would like to load this, or another config press the load button in either the xconfig or gconfig window. An example image is below:
NOTE If you system is not close to mine this config will not work for you
- make install - This will copy the files, modules, create the bootdisk image and even edit the bootloader configuration so it will be on the boot menu next time the machine is booted. User root needs to run this command from the directoty where the kernel was compiled.
There are other steps one can take but these should not be needed.
A quick word about patching your kernel If you do need to, or simply want to patch your kernel then it is quite easy. Download the patch and move it to /usr/src/. If it is compressed uncompress (e.g. gunzip patchname.gz) it and the cd into the directory /usr/src/linux and type this: patch -p1 < ../patch_name.patch Here is an example, while in the directory /usr/src/linux and the patch 2.6.9.patch is in /usr/src/ type patch -p1 < ../2.6.9.patch and the 2.6.9 patch is applied. Walla!
Thanks to the original kernel how-to writer Brian Ward and his how-to found at http://www.linuxdoc.org/HOWTO/Kernel-HOWTO.html . Also to Compunuts for motivating me!