view · edit · history · print

Compiling the Linux kernel

Software you need

  • Get your source [the bz2 compressed kind] from the site. No kids games using rpm or deb packages here ;-)
  • bzip2
  • patch
  • ncurses-devel (libncurses5-dev)

The process

  • Unpack
    $ bzip2 -dc linux-xxx.tar.bz2 | tar -xvf -
    $ cd linux-xxx
    $ bzip2 -dc ../xxx-test5-mm3.bz2 | patch -p1
  • Link Linux
    $ rm /usr/src/linux
    $ ln -s /path/to/srcdir /usr/src/linux
    $ cd /usr/src/linux
  • Use the old ".config" or create a new one
    $ make clean; make mrproper; make clean
    $ make menuconfig (set your TERM first)
  • make dep (only for 2.4 kernels)
  • vi Makefile (to change EXTRAVERSION if wanted)


EXTRAVERSION deserves a little more comment. At the top of the Makefile, 4 variables are set, VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION. The first 3 denote the exact version of your source code. You should never change these values. But the last denotes the version of the kernel build. These 4 values get concatenated together to produce your kernel's name. You can get your current kernel's name with 'uname -r', which could look like "2.4.21-0.13mdk", "2.4.21-0.13mdksecure", "2.4.21-0.13mdksmp", or "2.4.21-0.13mdk_garricks_build_005". Everything from the "-" is the EXTRAVERSION.

The kernel's name is important. Modules check the version name before they are loaded, modules are stored in a directory with the kernel name, the system map is stored with the kernel name, and other important things.

If you are preparing your source to build a module for your existing kernel, then setting EXTRAVERSION is very important, and sometimes slightly tricky. You want to remove "VERSION.PATCHLEVEL.SUBLEVEL" from your kernel's uname and put the rest in EXTRAVERSION. For example, if you are running 2.4.21-0.13mdksecure, then you would set EXTRAVERSION to "-0.13mdksecure". If you are running, then it should be ".1-12mdk-i586-up-1GB". Often, you can just remove the "custom".

If you are building a whole new custom kernel for yourself, be sure to set a unique EXTRAVERSION so that your new kernel doesn't clobber your existing kernel. A convention for new kernels build could be "-build999<-note>", where 999 is the compile run, and "note" is an optional identifier.

After changing the EXTRAVERSION, run 'make clean' and 'make dep'. (clean isn't necessary above because we just ran mrproper, which is a super clean) (make dep is no longer used for 2.6 kernels).

  • Compile the kernel
    $ nohup make bzImage &
    # or, even better...
    $ make bzImage && make modules && make modules_install
    # for compilation of the whole thing.
  • Install the new kernel
    $ mv arch/i386/boot/bzImage /boot/bzImage-2.6.0-test4 
    $ mv /boot/ 
    $ mv .config /boot/config-2.6.0-test4 
    $ cd /boot
    # optional, change defaults
    $ ln -sf
    $ ln -sf bzImage-2.6.0-test4 ../vmlinuz
    # Donnot forget to configure lilo/grub!!

Configuration considerations

AH transformation
ESP transformation
IPsec User configuration interface
(also crypto API is selected)

network packet filtering
 ip tables support

power management support

preemptible kernel

 pentium III celeron (coppermine)

support for usb
 usb mass storage support


Specific Hardware

admin · attr · attach · edit · history · print
Page last modified on August 09, 2006, at 11:52 AM