Next Previous Contents

2. Quick Steps - Kernel Compile

This section is written by Al Dev

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. 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.

  1. Login in as 'root' throughout all these steps. Mount Redhat linux cdrom and install the linux kernel source rpm
    bash$ su - root
    bash# cd /mnt/cdrom/RedHat/RPMS 
    bash# rpm -i    kernel-headers*.rpm 
    bash# rpm -i    kernel-sources*.rpm 
    bash# rpm -i dev86*.rpm   
    bash# rpm -i bin86*.rpm   
    

    (The bin86*.rpm and 'as86' is required only for OLDER Linux systems like redhat 5.x. Get Intel assembler 'as86' command from dev86*.rpm on cdrom or from http://rpmfind.net/linux/RPM/mandrake/7.1/Mandrake/RPMS/bin86-0.4-12mdk.i586.html , http://rpmfind.net/linux/RPM/kondara/jirai/i586/bin86-0.4-8k.i586.html ).

  2. Start X-windows with 'startx'.
    bash# man startx
    bash# startx
    bash# cd /usr/src/linux 
    bash# make xconfig 
    

    The "make xconfig" brings up a user friendly GUI interface! DO NOT use 'make config' which is a command-line option ( use this only if you CANNOT bring up X-window). You load the configuration file from /usr/src/linux/arch/i386/config.in

  3. Enable the Loadable kernel modules support! With this option you can load/unload the device drivers dynamically on running linux system on the fly. See these man pages
    bash# man lsmod
    bash# man insmod
    bash# man rmmod
    bash# man depmod
    

  4. Save and Exit "make xconfig". And now, do -
    bash# make dep
    bash# make clean
    

  5. Read the following file (to gain some knowledge about kernel building...) -
    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. 
    

  6. Now, give the make command -
            bash# cd /usr/src/linux
            bash# man nohup
            bash# nohup make bzImage &  
            bash# tail nohup.out     (.... to monitor the progress) 
    This will put the kernel in /usr/src/linux/arch/i386/boot/bzImage 
            bash# man tail 
    

  7. After bzImage is successful, copy the kernel image to /boot directory. You must copy the new kernel image to /boot directory, otherwise the new kernel may not boot. And then read the manual page on lilo (see also http://www.linuxdoc.org/HOWTO/LILO-crash-rescue-HOWTO.html) -
    bash# cp /usr/src/linux/arch/i386/boot/bzImage     /boot/bzImage.myker  
    bash# man lilo
    bash# man lilo.conf
    And edit /etc/lilo.conf file and put these lines - 
            image=/boot/bzImage.myker 
            label=myker 
            root=/dev/hda1 
            read-only 
    You can check device name for 'root=' with the command - 
            bash# df   /boot 
    

  8. Now give
    bash# lilo 
    bash# lilo -q 
    

    You must re-run lilo even if entry 'myker' exists, everytime you create a new bzImage.

  9. Reboot the machine and at lilo press tab key and type 'myker' If it boots then you did a good job! Otherwise at lilo select your old kernel, boot and re-try all over again. Your old kernel is still INTACT and SAFE at say /boot/vmlinuz-2.0.34-0.6

  10. Loadable Modules: Boot new kernel and install the loadable modules from RedHat Linux cdrom
    bash# rpm -i /mnt/cdrom/contrib/kernel-modules*.rpm 
    ....(For old linux systems which do not have insmod pre-installed) 
    bash# man insmod
    bash# insmod  
    

  11. If your linux is already had loadable module enabled, then check for files in /lib/modules. The step given below may not be needed. Build modules by installing kernel-source*.rpm and kernel-headers*.rpm.
    bash# cd /usr/src/linux
    bash# make modules
    bash# make install_modules
    

  12. If your new kernel 'myker' boots and works properly, you can create the boot disk. Insert a blank floppy into floppy drive and -
    bash# cd /usr/src/linux
    bash# make bzdisk
    See also mkbootdisk -
    bash# rpm -i mkbootdisk*.rpm
    bash# man mkbootdisk
    


Next Previous Contents