WARNING!
A custom kernel compile is a very complicated procedure. Use this procedure only if there are no packages in the debian repository that can get your hardware/software configuration working for you. New users should read up on debian kernel compiles and kernel compiles in general before attempting this. This guide, its author(s), and/or contributors, are not responsible for any damage inflicted on your system by following these instructions. You compile and use a custom kernel at your own risk.
The following instructions detail a compile of a 2.6.xx kernel using The Debian Way. Please tell me if there are any errors/omissions, so that I can add them.
Note!
The following how-to assumes that you are running at least Debian 3.1, Sarge.
Step 1: Assuming that you have access to the internet and have installed a minimal debian install (netinstall iso), as root, type:
Code:
example:~# aptitude -r install kernel-package ncurses-dev fakeroot wget bzip2 kernel-tree-2.6.8 alsa-source
This should install all the packages required for a successful compile. The alsa-source package is to ensure that you sound works when running on your custom kernel.
Step 2 (Optional): If you do not want to use the debianized kernel, you can download a newer kernel from kernel.org. This is what is done next:
Code:
example:~# aptitude install ncftp
....
example:~# cd /usr/src
example:/usr/src# ncftp ftp.se.kernel.org
....
ncftp / > cd pub/linux/kernel/v2.6/
....
ncftp /pub/linux/kernel/v2.6/ > get linux-2.6.11.12.tar.bz2
....
Transfer Complete!
ncftp /pub/linux/kernel/v2.6/ > bye
....
Save? (yes/no) no
....
example:/usr/src#
Of course, use a mirror that is close to you (check for addresses on kernel.org) and grab the latest kernel version. At the time of this writing, it was 2.6.11.12.
Step 3: Now untar the linux and alsa source packs, and make the appropriate symlink.
Code:
example:/usr/src# tar xvfj linux-2.6.11.12.tar.bz2
....
example:/usr/src# tar zvfj alsa-driver.tar.bz2
....
example:/usr/src# ln -s linux-2.6.11.12 linux
Step 4 (Optional): Edit the makefile.
Code:
example:/usr/src# cd linux
example:/usr/src/linux# nano Makefile
You may want to edit the EXTRAVERSION clause to insert something more descriptive. For example:
Code:
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 11
EXTRAVERSION = .11-pentium-m
NAME=Woozy Beaver
Step 5: Now comes the tricky part, kernel configuration. There are three ways to configure the kernel to suit your needs. Each will be described below.
Code:
example:/usr/src/linux# make config
This is the hardest way, and will present you with an almost endless stream of questions. Using this form of kernel compile assumes that you know exactly what you are doing. Answer one question wrong, and you have to start over. It is not recommended that you use this option.
Code:
example:/usr/src/linux# make menuconfig
This way is a lot easier, and will present you with a menu driven configuration interface in your console. You can select the configuration options you want, and when you are done, you can save your config file and proceed directly to a compile. An internel help system for each item is also available if you are unsure as to whether you need a component or not.
Code:
example:/usr/src/linux# make xconfig
This assumes that you have an X server available. The configuration interface is similar to that of menuconfig, but much easier to operate because it uses a graphical user interface. In debian, root cannot run X applications. Thus, after running this command, you have to run it again as a user.
Code:
user@/usr/src/linux$ make xconfig &
Personally, this guide recommends that you use menuconfig, and if possible, xconfig.
When you are done configuring using xconfig, you have to save your configuration file in your home directory, and then, using the root account, copy it to your /usr/src/linux directory.
Code:
example:/usr/src/linux# rm .config
example:/usr/src/linux# cp /home/user/myconfig .config
A few tips when configuring the kernel:
A. When a device driver is to be compiled into the kernel, it is designated by a star (menuconfig) or check (xconfig). When it is to be compiled as module, it is designated by an "M" (menuconfig), or round dot (xconfig).
B. Make sure that the IDE/SCSI and filesystem device drivers for your particular computer/root filesystem are compiled into the kernel. Otherwise your new kernel will not boot. This is done in "Device Drivers > Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support" and/or, "Device Drivers > SCSI device support", and "File systems" for filesystems.
For example, include support for IDE disk/cdrom/floppy support, along with ex3/reiserFS support, depending on which filesystem you use.
C. Make sure that the drivers for your particular graphics card is compiled into the kernel. Otherwise, you'll just get a blank screen. This is done in "Device Drivers > Character Devices" and "Device Drivers > Graphics support".
D. Compile all drivers for the hardware that is currently in use into the kernel. This will improve performance considerably. An exception to this is sound. All sound related components MUST be compiled as modules. Otherwise they will not work correctly.
Step 6: Now what we have all been waiting for, the kernel compile. After you have configured your kernel, and copied/moved the configuration file to the correct location (if using xconfig), type:
Code:
example:/usr/src/linux# make-kpkg clean
....
example:/usr/src/linux# time make-kpkg -revision 2.6.11.12 -append-to-version -pentium-m kernel_image kernel_headers modules_image
....
Note: Multiple kernel compiles using the same source MUST use the same revision. The revision string, once set, cannot be changed. The -append-to-version option does the same thing as appending the EXTRAVERSION section in the makefile.
Now sit back and wait, this is going to take awhile. The time command is so that you can see how long it took for you to compile your kernel.
Step 7: If your kernel compiled successfully, it's time to install it. If it did not, go back and reconfigure the kernel, and repeat step 6. The following commands installs the completed debs. Obviously your files are going to be named differently.
Code:
example:/usr/src/linux# cd ..
example:/usr/src# dpkg -i alsa-modules-2.6.11.12-0-pentium-m_1.0.8-7+2.6.11.11_i386.deb kernel-headers-2.6.11.12-0-pentium-m kernel-image-2.6.11.12-0-pentium-m_2.6.11.11_i386.deb
....
example:/usr/src#
IMPORTANT!
DO NOT uninstall your old kernel. You will most probably need it, since your newely compiled kernel will most likely contain fatal configuration errors.
Step 8: Now comes the moment of truth, the reboot. Type:
Code:
example:/usr/src# reboot
Select the new kernel from your grub bootlist. If the system successfully boots, congratulations. If it does not, (this is why you SHOULD NOT uninstall a kernel until you have verified that the new one works), boot back with the working kernel, reconfigure, and try again.