Originally Published: Tuesday, 3 July 2001 Author: Subhasish Ghosh
Published to: develop_articles_tutorials/Development Tutorials Page: 1/1 - [Printable]

More on Custom Kernels

Subhasish Ghosh and Linux.com return with a revised follow-up version the 27 magical steps involved in compiling, configuring and installing and custom Kernel in Red Hat. In this article Ghosh goes into more depth on some kernel options, works with 2.4 and answers many of the questions generated by his last article on the subject.

   Page 1 of 1  

This article provides you with a detailed step-by-step process describing how to Compile, Configure and then install a basic Custom Kernel 2.4. As we all know, a Customized Kernel is required for many reasons, and I will not go into those details: I will only show how to do it, not why you would want to. This article is a follow up to my previous article on compiling a basic Kernel. Today we will go into a little more depth on some important steps.

Please note that I have performed all the steps mentioned below on a computer system with the following configurations: Compaq Presario 4010 Series computer system, 15.5 GB Hard Disk Space, 96 MB RAM, 400 MHz Intel Celeron Processor, Red Hat Linux 7.1 Distribution Release underlying Kernel: 2.4.2-2

The steps to be followed are as follows: Step 1: Login as "root" and then perform these steps.

Step 2: At the command prompt, type in: rpm -q kernel-headers kernel-source make dev86

Step 3: If these RPMs are already installed, then proceed to step 4. Otherwise, mount the Red Hat Linux 7.1 CD-ROM and then perform a rpm -Uvh for installing these RPMs.

Step 4: If you have a fully working X Window System, then type in "startx" at the command prompt. In case you don't have an X Window System configured, then proceed to Step 5. Please note: When I have X configured, I use 'xconfig', but using 'menuconfig' from the Command line is fine too.

Step 5: At the prompt type: cd /usr/src/linux-2.4.2 and press enter. Please note this step. Earlier, while compiling the 2.2 Kernel, the path used to be /usr/src/linux, it's now at /usr/src/linux-2.4.2

Step 6: From within /usr/src/linux-2.4.2, type in "make menuconfig".

Step 7: This provides you with the various options you have for obtaining a Customized Kernel. Kernel 2.4 provides exactly 29 sections that you can try for building your own Customized Kernel. They are as follows:

  1. Code maturity level options
  2. Loadable module support
  3. Processor type and features
  4. General setup
  5. Memory Technology Devices(MTD)
  6. Parallel port support
  7. Plug and Play configuration
  8. Block devices
  9. Multi-device support(RAID and LVM)
  10. Networking options
  11. Telephony support
  12. ATA/IDE/MEM/RLL support
  13. SCSI support
  14. Fusion MPT device support
  15. IEEE 1394 (Firewire support)
  16. I2O device support
  17. Network device support
  18. Amateur Radio support
  19. IrDA (infrared) support
  20. ISDN subsystem
  21. Old CD-ROM drivers
  22. Input Core support
  23. Character devices
  24. Multimedia devices
  25. File systems
  26. Console drivers
  27. Sound
  28. USB support
  29. Kernel hacking

Step 8: Now, I would really suggest you leave most of the default options just as they are. Just don't try to fiddle around right here because most of the options are sensitive and require expert handling. You can always come back later when you have something specific you want to compile. At this point though, just make the following changes:

  1. Code maturity level options: Select the option "Prompt for development and/or incomplete code/drivers" [*]Prompt for development and/or incomplete code/drivers For testing and/or developing a driver that is currently in "Alpha-test" phase, you should select this option, otherwise don't. If you do select this option, drivers/features currently in the "Alpha-test" would be available for use.
  2. Loadable module support:
    [*] Enable loadable module support Modules (device drivers, file systems etc.) are to be used with this Kernel in the future.
    [*] Set version information on all module symbols For availability of same modules even after compiling a new Custom Kernel. Make sure you have the program 'genksyms', otherwise Kernel compilation would fail.
    [*] Kernel module loader The Kernel loads the required modules by running modprobe with appropriate arguments.
  3. Processor type and features: Choose the correct Processor type depending on whether you are working on a Pentium 2, 3, or Intel Celeron like me. Kernel 2.4 provides you with a wide range of choices. They are as follows:


    ( )386 -> AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI, 486DLC/DLC2, UMC 486SX-S and NetGen Nx586
    ( )486 -> MD/Cyrix/IBM/Intel 486DX/DX2/DX4 or SL/SLC/SLC2/SLC3/SX/SX2
    ( )586/K5/5x86/6x86//6x86MX -> Generic Pentium
    ( )Pentium-Classic
    ( )Pentium-MMX -> Intel Pentium/Pentium MMX, AMD K5,K6 and K63D
    ( )Pentium-Pro/Celeron/Pentium-II -> Cyrix/IBM/National Semiconductor 6x86MX, MII and Intel Pentium II/Pentium Pro
    ( )Pentium III -> Intel Pentium III
    ( )Pentium 4 -> Intel Pentium 4
    ( )K6/K6-II/K6-III -> AMD K6, K6-II and K6-III
    ( )Athlon/Duron/K7 -> AMD Athlon
    ( )Crusoe -> Self-modifying low-power CPU from Transmeta Corp.
    ( )Winchip-C6 -> IDT Winchip
    ( )Winchip-2 -> IDT Winchip2
    ( )Winchip-2A/Winchip-3 -> IDT Winchips with 3dNow

    Kernel 2.4 provides you with these above-mentioned choices from which you can select your processor type. Make sure this selection is correct, cause Kernel compilation depends a lot on these factors. I am using an Intel Celeron processor, for that reason, I chose the option: ( )Pentium-Pro/Celeron/Pentium-II (X)Pentium-Pro/Celeron/Pentium-II

    Make sure you leave the other options as they are. Now, let's take a look at the other significant options that we need to change or alter within "Processor type and features". Move a little down and you can see an option that reads:


    ( )High Memory Support
    Press enter, and you are provided with 3 options further:
    ( )off
    ( )4GB
    ( )64GB

    Linux will support up to 64 gigabytes of RAM, but this support must invoke Intel Physical Address Extensions (PAE) to use the memory above the 4GB limit. All Intel Pentium series CPUs including the new ia64 support PAE, but enabling this option will crash on CPUs that do not support PAE. For systems requiring between 1GB and 4GB RAM, the 4GB option will split memory into a 3GB space useable by applications and a 1GB portion for internal use by the Linux Kernel. If you are compiling a Kernel that will never run on a machine with more than 1 GB total Physical RAM, select "off". This is the choice for most users. Selecting ( )off, will result in the following:


    (off)High Memory Support
    Next, set the option ( )Maximum Virtual Memory. Highlight it and press enter. You are provided with the following options:
    ( )3GB
    ( )2GB
    ( )1GB
    I selected the option ( )1GB, so make sure it looks like this: (X)1GB

    Next we come to the option: [ ]Math Emulation

    This was the center of much debate in my last article "Compiling, configuring and installing a Kernel", published at this very site on June 20th 2001. Please note, according to the "Help" included with the Red Hat Linux 7.1 Distribution Release, underlying Kernel 2.4.2.-2 regarding whether one should answer Yes or No here, this makes no difference at all for processors that already have a "math coprocessor" built in. 486SX and 386 processors do not have a "math coprocessor", while Pentium processors do have. As I am using a Celeron processor, I don't require this option, but if you have "cross-platform portability" in mind, the best option would be to select this option and include it for a safe Kernel compilation. If you are not sure, the best option is to say "Yes": apart from a bigger Kernel by 66KB, it wouldn't hurt much. I like playing safe, so I selected "Yes". If you want, you can do otherwise.

    Next comes the option: [ ]MTRR(Memory Type Range Register) support
    X Server needs this for performance. Ought to be selected: [X]MTRR(Memory Type Range Register) support

  4. Next we come to the choice that reads: Multi-device support(RAID and LVM)

    If you need RAID(Redundant Arrays of Inexpensive Disks) support in your new Kernel, make sure you spend some time with the options provided below, otherwise simply leave them out. I needed to do some R&D with RAID support in Kernel 2.4, so I selected the options outlined below:


    [*]Multiple devices driver support(RAID and LVM)
    <*>RAID Support
    <*>Linear(append) mode
    <*>RAID-0(striping) mode
    <*>RAID-1(mirroring) mode
    <*>RAID-4/RAID-5 mode
    <*>Multipath I/O support (A multipath RAID device costs of a disk with several different IO routes configured to this disk. For selecting RAID-1 set, this must be selected also.)
    <*>Logical Volume Manager(LVM) support (This driver lets you combine several hard disks, hard disk partitions, multiple devices or even loop devices (for evaluation purposes) into a volume group like a Virtual disk.)

  5. Next we need to look at the option: File systems. For the support of different file systems I need to re-compile my Linux Kernel from time to time and increase the read-write and accessibility performance by a considerable margin. The choices that I have had selected are as follows:


    [*]Quota support
    <*>Kernel automounter support
    <*>Kernel automounter version 4 support(also supports v3)
    <*>DOS FAT fs support
    <*>MSDOS fs support
    <*>UMSDOS
    <*>VFAT(Windows-95) fs support
    <*>NTFS filesystem support(read-only)

    If you are like me and also in love with FreeBSD, and need to access the FreeBSD partitions from within Linux, you have to include the FreeBSD filesystem support also. For that purpose, do the following: Move to the bottom of the 'File systems' screen, and then select the option that reads: < >UFS filesystem support(read-only) Should be selected: <*>UFS filesystem support(read-only). Next, move to the option that reads "Partition types", highlight it, and then press enter. On the next screen, the following options should be selected:


    [*]Advanced partition selection
    [*]PC BIOS(MSDOS partition tables) support would be selected by default. Don't change.
    [*]BSD disklabel(FreeBSD partition tables) support (Choosing this option ensures that FreeBSD disklabels are visible from the Linux environment, in addition you can also mount FreeBSD partitions from within Linux.)

    Note: An important point to remember is that < >UFS filesystem support(read-only) must be selected, otherwise, Kernel compilation will fail.)

  6. The Kernel 2.4 provides a lot of Networking Options. I included the following for a basic setup:


    <*>Packet socket
    [*]Kernel/User netlink socket
    [*]Routing messages
    [*]Network packet filtering(replaces ipchains)
    <*>Unix domain sockets
    [*]TCP/IP networking
    [*]IP:multicasting

    (i) Packet socket: The packet protocol is used by applications that communicate directly with network devices without an intermediate network protocol implemented in the Kernel.

    (ii) Kernel/User netlink socket: Allows a two-way communication between the Kernel and user processes. If you want to use arpd, a daemon that keeps the internal ARP cache, which is the mapping between IP addresses and hardware addresses on the local network, small, then this option should be selected.

    (iii) Routing messages: If selected, user space programs can receive some network related routing information over the netlink.

    (iv) Network packet filtering (replaces ipchains): Select if you intend using your Linux system as the gateway to the Internet using "masquerading". Select this option if you want to run your Red Hat Linux system as a Router. In other words, for creating a "routing enabled kernel".

    After you have made these changes, please make sure you haven't changed the others in the process. All these above-mentioned changes are quite harmless and won't cause any harm to your existing Linux Kernel. Save and Exit from the Main dialog.

Step 9: Perform a "ls -al" from within the path: /usr/src/linux-2.4.2

Step 10: You will see a file called: "Makefile". Makefile is an extremely important file for this entire Compilation process. So, make sure you create a backup of this file, by using: cp Makefile Makefile.bak

Step 11: Now, do: (from within /usr/src/linux-2.4.2) vi Makefile

Step 12: Go to line EXTRAVERSION and change it to something you like. For example, I changed EXTRAVERSION=-2, to EXTRAVERSION= "-2ghosh". You are free to name it any way you wish.

Step 13: Save and exit the file.

Step 14: All the following steps should be done from within: /usr/src/linux-2.4.2. Type in: "make dep clean", and press enter.

Step 15: Then type in: "make bzImage modules" for creating the file bzImage. This could take some time, go and have a drink while it compiles all the necessary files. Or you can check out the new game "XBill" on another machine if you want to!

Step 16: After this step is over, a "bzImage" file would be created in the directory /usr/src/linux-2.4.2/arch/i386/boot, just go to this directory and check whether a file called "bzImage" has been produced or not. IF AND ONLY IF all the compilation steps have been executed correctly and all the options that we have had chosen in "make menuconfig" are correct, this file would be produced. If you can find this file, which I am sure you will be able to, well, you can start enjoying life already, cause you have won 75% of the battle. If you can't see this file, I am sorry, but you must have had made a mistake somewhere: Take a break and carry out all the steps again from the start. I am sure you will eventually succeed. Note: Your build process successfully creates System.map, bzImage and modules.

Step 17: After bzImage is successful, copy the kernel image to /boot directory. If not done, the new Kernel MAY NOT boot. From within /usr/src/linux-2.4.2 type: cp ./arch/i386/boot/bzImage /boot/vmlinuz-2.4.2-2ghosh and press enter.

Step 18: Then type in: cp System.map /boot/System.map-2.4.2-2ghosh

Step 19: Then type: "make modules_install" and press enter. You would see all the modules being installed in a new customized directory.

Step 20: Now type in: mkinitrd /boot/initrd-2.4.2-2ghosh.img 2.4.2-2ghosh and press enter. This creates the Initial RAM-disk Image for our newly created customized Kernel.

Step 21: Then, type in: vi /etc/lilo.conf and then add the following entry:
image=/boot/vmlinuz-2.4.2-2ghosh
label=GhoshKernel
initrd=/boot/initrd-2.4.2-2ghosh.img
root=/dev/hdc5
read-only

Step 22: Save and exit. Please note that you can also change the entries in the lilo.conf file as you desire, and the root should be the root in your system: in my machine, it's at /dev/hdc5. Insert the correct info from your system.

Step 23: Type in: /sbin/lilo -v -v

Step 24: Read all the info on the screen. If there are no errors, well, the job's all done. Congratulations!

Step 25: Reboot the system by typing in: /sbin/reboot or /sbin/shutdown -r now.

Step 26: In the start-up screen, press Tab (or Control-X, if you have the LILO start-up screen), and you can see the entry: GhoshKernel along with the other pre-existing entries.

Step 27: Type in: GhoshKernel and press enter. The fully working Customized Kernel will boot your system.

So, you have a fully working Customized Kernel working on your system. After logging in as "root", type in: uname -r and press Enter. You can see the following entry on the screen: 2.4.2-2ghosh that proves that you are running a Customized Kernel. That's all. Also remember, that you can have as many Kernel versions as you like.

That's all there is to it. In case this doesn't work out or you guys and gals face problems, make sure you e-mail me at: auspicious_blessingsindia@hotmail.com for questions and suggestions. I would really like to hear from you and help you and I hope this article helps everyone out there who wants to run a fully working Customized Kernel.

Please note: This article is NOT by any means exhaustive and it does not cover all the options that one can take into consideration while compiling Kernel 2.4. The Kernel 2.4 provides 29 options in "menuconfig", and one needs to check out the others that I haven't covered here for any special requirements. This article provides one with the basic steps required for compiling and installing a customized 2.4 Red Hat Linux Kernel.





   Page 1 of 1