This section is written by Al Dev (alavoor@yahoo.com)
The latest version of this section is at http://www.aldev.8m.com and click on "Quick Steps to recompile linux kernel". Mirror sites are at - http://aldev.webjump.com, angelfire, geocities, virtualave, bizland, theglobe, spree, infoseek, bcity, 50megs, NBCi, Terrashare, Fortunecity, Freewebsites, Tripod. These sites have lots of linux goodies and tips.
A copy of the above web-site is reproduced here -
Kernel re-compile is required in order to make the kernel very lean and which will result in FASTER operating system . It is also required to support any new devices. Note: Below 'bash#' denotes the bash prompt, you should type the commands that appear after the 'bash#' prompt. Below are commands tested on Redhat Linux, but it should work for other distributions with very minor changes.
bash$ su - root bash# cd /mnt/cdrom/RedHat/RPMS bash# rpm -i kernel-headers*.rpm bash# rpm -i kernel-source*.rpm bash# rpm -i dev86*.rpm bash# rpm -i bin86*.rpm
bash# man startx bash# startx bash# cd /usr/src/linux bash# make xconfig
bash# man lsmod bash# man insmod bash# man rmmod bash# man depmod
bash# make dep bash# make clean
bash# gvim -R /usr/src/linux/arch/i386/config.in bash# man less bash# less /usr/src/linux/arch/i386/config.in Type 'h' for help and to navigate press i, j, k, l, h or arrow, page up/down keys.
bash# cd /usr/src/linux
bash# man nohup
bash# nohup make bzImage &
bash# tail -f nohup.out (.... to monitor the progress)
This will put the kernel in /usr/src/linux/arch/i386/boot/bzImage
bash# man tail
bash# cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.myker.26mar2001
bash# man lilo
bash# man lilo.conf
And edit /etc/lilo.conf file and put these lines -
image=/boot/bzImage.myker.26mar2001
label=myker
root=/dev/hda1
read-only
You can check device name for 'root=' with the command -
bash# df /boot
bash# lilo bash# lilo -q
bash# man insmod bash# insmod bash# rpm -i /mnt/cdrom/Redhat/RPMS/modutils*.rpm
This will list the already installed package.
bash# rpm -qa | grep -i kernel
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i686.rpm
(or)
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i586.rpm
(or)
bash# rpm -U --force /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i386.rpm
bash# rpm -i /mnt/cdrom/contrib/kernel-modules*.rpm ....(For old linux systems which do not have insmod pre-installed)
bash# cd /usr/src/linux bash# make modules bash# make modules_install
bash# cd /usr/src/linux bash# make bzdisk See also mkbootdisk - bash# rpm -i mkbootdisk*.rpm bash# man mkbootdisk
The following mistake is commited very frequently by new users.
If your new kernel does not boot and you get -
Warning: unable to open an initial console Kernel panic: no init found. Try passing init= option to kernel
The kernel looks for the init command which is located in /sbin/init. And /sbin directory lives on the root partition. For details see -
bash# man init
Given below is a sample /etc/lilo.conf file. You should follow the naming conventions like ker2217 (for kernel 2.2.17), ker2214 (for kernel 2.2.14). You can have many kernel images on the same /boot system. On my machine I have something like:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
default=firewall
image=/boot/vmlinuz-2.2.14-5.0
label=ker2214
read-only
root=/dev/hda9
image=/boot/vmlinuz-2.2.17-14
label=ker2217
read-only
root=/dev/hda9
#image=/usr/src/linux/arch/i386/boot/bzImage
# label=myker
# root=/dev/hda7
# read-only
image=/boot/bzImage.myker.11feb2001
label=myker11feb
root=/dev/hda9
read-only
image=/boot/bzImage.myker.01jan2001
label=myker01jan
root=/dev/hda9
read-only
image=/boot/bzImage.myker-firewall.16mar2001
label=firewall
root=/dev/hda9
read-only