Home Previous Up Next4.7. Build the Linux Kernel yourself.
About
Contents
Projects
Thwab
Articles
Downloads
عربي

4.7. Build the Linux Kernel yourself.

Section quotes:

  • "``You cannot use a computer WITHOUT compiling the OS kernel with your own hands''. If you disobey this law you will be ``punished'' with lot of computer problems!!"
        -- Alavoor Vasudevan (AlDev)
  • "It should be a case of 'Just plug in a new kernel, and suddenly your existing filesystem just allows you to do more! 20% more for the same price!' (...)"
        -- Linus Torvalds on LKML

Section contents:

4.7.1. Why should I do that ?

It's very funny to make the core of your compute OS with your own bare hands, it's a feeling you should not miss, every expert Linux user should do that (at least once), not because it's difficult but to know all tasks kernel do. Any way those are most important reasons to do that:

  • top reliability, you made it yourself.
  • meet new hidden things that you never heard while you do configuration.
  • get too new next generation kernel, before it is shipped on distributions.
  • enjoy new drivers, or new supported features of old drivers, for example there are better support for ALSA sound driver on 2.6 kerenl that replaces OSS driver.
  • you may like to compile an old kernel because you have an old binary only driver like Motorola SM56 which is no more produced that only work with 2.4.5 kernels
  • you could make a custom kernel for specific needs, a too small and fast kernel, which driver is built into the kernel ,which is loaded on demand and which is left.
  • you could look at C files and read comments, it's your last hope to know how let kernel do something.

4.7.2. Where can I get it ?

You could get relatively old Linux kernel source from your distributiton CDs (eg. 3rd CD) as a source package, but to get any version you could download it from 'www.kernel.org' as a tarball ('.tar.gz' or a smaller '.tar.bz2'), please no that this site does not call it kernel butt it call it 'linux'.

4.7.3. Let's start.

Copy the file tthen decompress it to '/usr/src/linux', usually (specially if you have more than one version) decompress it on for example '/usr/src/linux-2.4.22' then link it to the standard '/usr/src/linux' with something like 'cd /usr/src; ln -s linux-2.4.22 linux' then be there 'cd /usr/src/linux'. The first step is to make sure you have a clean start (remove junk files) using 'make clean ; make mrproper ' even if it's your first time and there are no such files. Now create the configurations, you could copy it from old trials, also you use interactive tools to create this file, like 'make menuconfig' - a nice menu driven console inteface (ncurses and it's development should be installed), or the ugly TCL graphical interface with 'make xconfig', then select your configurations, then create pre requirments with 'make dep', then create a BZIP'ed kernel with 'make bzImage', this takes a long time, and create modules with 'make modules' (at another terminal to save time), when they are done use 'make modules_install' to copy modules where kernel can find them ('/lib/modules'), when you finish all compiling copy the kernel where LILO/GRUB can find it ('/boot') then configure them to add this kernel to boot menu along with your old kernel in case that the new is borken, reboot and test it, if every thing is Okay you could remove object and other temporary files, also you could create RPM file so you could use it else where. Those are the commands: (you could try it without 'nohup' if you are not familiar with this tool)

bash$ su
bash# cd /usr/src
bash# ln -sf linux-2.4.24 linux
bash# cd linux
bash# pwd
/usr/src/linux
bash# make clean ; make mrproper
bash# make menuconfig
bash# make dep
bash# nohup make bzImage & 
# you can see the file nohup.out by tail -f nohup.out
bash# nohup make modules 1> mod.out 2> mod.err & 
# to check the progress tail -f mod.out or tail -f mod.err
# wait to finish making the modules then type
bash# make modules_install
# wait to finish making the kernel then type
bash# cp /usr/src/linux/arch/i386/boot/bzImage /boot
# remove intermedite files do
bash# make clean
# if you wnt you can make rpm
bash# make rpm
failed, why ? see error messages on the screen or at 'nohup.out' file. If there is a missing packages, install it along with it's development package, for example install 'ncurses' and 'ncurses-devel' (or 'ncurses-dev' in Debian) and so on. Beside libraries you need GNU C compiler and 'glibc-devel' ... etc.

 Tip

You could give your kernel a unique, just edit the Makefile then and modify 'EXTRAVERSION' line to be what ever you like.

 Tip

Replace 'bzImage' with 'zImage' to create a conventional GZIPed kernel (ie. 'vmlinuz') instead of bz2 kernel (support larger size, and better compression).

 Tip

You could make compiling much faster with '-jN' option where N is an integer number like 'make modules -j2' this will start two processes (two compilers) at a time. Some TLDP HOWTOs suggest N to be ram size / 8 (measured in megabytes) when you compile modules.

4.7.4. Compile time configurations.

When you issue 'make menuconfig', 'make xconfig' or 'make config', make sure you notice:

  • select right processor type, for example Pentium I kernel will work on Pentium IV but not the opposite, the last is faster when you run it on right CPU.
  • enable SMP if you have multiple processors.
  • enable modules, it's run-time plugins or drivers loaded on demand (when you use a device it's loaded and when it's released the module is unloaded to free memory), make sure you select 'kernel module loader' and 'loadable module support', unless you know what you are doing (making a rescue disk that uses no modules).
  • Make sure you support (directly not as modules) 'ext2', 'ext3', 'vfat', 'msdos' and 'minix', but other systems could be supported as modules 'reiserfs', 'ntfs', 'hpfs', 'jfs' and 'xfs' to save memory.
  • if 'menuconfig' does not look good try 'export TERM=linux' or 'export TERM=ansi', and try again, if you are not satisfied use 'make xconfig'.

ToC
Copyrights & Copylefts
What is Linux?
How to install Linux?
Halloween Documents

ArabEyes
Wikipedia
OpenSource
GNU
FSF's FSD
OSI's OSD
Linux.org
Linux.com
LinuxToday
SlashDot
FreshMeat
LWN.net

About Islam
What is Islam ?
We love Jesus; honored and not crucified.
Do you love Jesus or Paul ?
Who is Muhammad [PBUH] ?
Articles
Your scanner works on Linux
Linux cleaning Windows Viruses
Report
Unwanted Advertisements
Bugs and misspellings
Dead links:

 

Best viewed with free web browsers

You may get more high quality software from here for free
proud to be 100% Microsoft FREE GNU FDL


Generously Hosted by www.JadMadi.net

Previous Up 4.7. Build the Linux Kernel yourself. Next
Copyright © 2007, Muayyad Saleh AlSadi