Build your own Slackware kernel Print E-mail
Written by Administrator   
Sunday, 30 December 2007 13:46

Slackware provides many out of the box kernels optimized to be supporting a vast of various hardware configurations. Drawback is these kernels are not optimized for a specific hardware configuration or to be running on best performance. Enough reasons for a customized kernel.

The good news is, doing so is quite easy on Slackware, compared with other major Linux distributions. This article covers important steps building a customized kernel for a Slackware box

 

General conditions

  • This article is about kernel 2.6.x. I have ported my system to 2.6 years ago, although Slackware was consistently using kernel 2.4. Kernel 2.6 became standard in Slackware release 12.0
  • Always have a functioning kernel (e.g. standard Slackware kernel) you can boot!
  • As a rule of thumb, only compile core functions statically in the kernel, use kernel modules for the hole rest. This way your kernel keeps thin and you become more flexible
  • If you are unsure about your hardware configuration, activate all modules in a specific kernel section. Your kernel will load any module needed in order to support your hardware configuration. Doing so is in general a good idea. The only drawback is that it will take more time to compile a large quantity of modules
  • Don't expect building your own kernel a matter of ten minutes (at least not for the first time). It will take quite some time, as there are many many kernel options to go trough
  • Consider to switch to the "GRUB" bootloader (no prerequisite). See specific article in doing so

 

Here is how it goes

Step 1:

Make yourself comfortable with the hardware configuration of your box. Look into /sys and /proc. Have a look on your vendors site and / or consult your mainboard manual. You should at least know:

  • CPU model
  • Chipset
  • SATA / IDE specifications
  • Network
  • Video
  • Sound

 

Examine your PCI configuration:

 

lspci

 

Verify loaded modules

 

lsmod

 

Step 2:

Grab the 2.6.x kernel you want from www.kernel.org. Grab also the corresponding .sign file.

 

Step 3:

Verify the kernel file signature:

 

gpg --verifiy linux-2.6.23.16.tar.bz2 linux-2.6.23.16.tar.bz2.sign

 

Step 4:

Copy the linux kernel source file to /usr/src and extract it.

 

cp linux-2.6.23.16.tar.bz2 /usr/src
tar xvfj linux-2.6.23.16.tar.bz2

 

Step 5:

If you never have customized a kernel before, you must now go trough hundreds of kernel parameters. Nevertheless, it is worth the effort. Remember:

  • Always have a functioning kernel (e.g. standard Slackware kernel) you can boot!
  • Only compile core functions statically in the kernel, use kernel modules for the hole rest
  • If you are unsure about your hardware configuration, activate all modules in a specific kernel section. Your kernel will load any module needed in order to support your hardware configuration

 

Start kernel configuration:

 

make menuconfig

 

Dont't be premature, these are the top level adjustments, there are hundreds of sub-options. If in doubt what to do, have a look onto your running kernel configuration (e.g. a standard Slackware kernel).

kernel

When finished, save configuration and exit. Type:

 

make bzImage && make modules && make modules_install

 

Step 6:

Copy the kernel and system map to the /boot folder.

 

cp arch/i386/boot/bzImage /boot/vmlinuz_2.6.23.16
cp System.map /boot/System.map_2.6.23.16

 

Modules already have been installed to /lib/modules

 

Step 7:

Create some symlinks.

In /usr/src type:

 

ln -s linux-2.6.23.16 linux

 

In /boot type:

 

ln -s System.map_2.6.23.16 System.map
ln -s vmlinuz_2.6.23.16 vmlinuz (optional)

 

Step 8:

Adjust your boot loader.

If you are a LILO user type "lilo"

if you are using GRUB adjust your /boot/grub/menu.lst file

 

Step 9:

Reboot!

If you utilize specific modules, e.g. a graphic driver or VMware workstation modules, you have to recompile them.

 

Step 10:

Delete unnecessary sources in:

  • /usr/src
  • /lib/modules
  • /boot

 

Upgrade your customized kernel

This is much more easier than customize a kernel for the first time. We distinguish:

  • Kernel patch upgrade, e.g. 2.6.23.15 to 2.6.23.16
  • Kernel minor release update, e.g. 2.6.23 to 2.6.24

You can do both by downloading the new full release or by just applying the a patch.

 

Step 1:

Kernel patch upgrade:

If you start with a new full release, extract it and then copy the .config file from the old kernel source tree into the new one. Type:

 

make oldconfig

 

If you just apply the patch, you don't have to do this.


Minor release update:

Proceed like described above, but there is a difference. As a new kernel version introduces new options not known to the previous kernel and its .configure file, you must set up these options first. To do so, simply answer the questions the "make oldconfig" scripts is going to ask you. Answer them with yes (y), no (n) or (m) for module.

 

Step 2:

Build your new kernel and modules.

 

make bzImage && make modules && make modules_install

 

Then proceed as described above.

Last Updated on Sunday, 10 June 2012 13:03
 

0 Comments

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)