The kernel needs to be streamlined for quicker access to your operating system and devices you really use. Kernel hacking isn't difficult, but it is risky and it's not recommended for users new to Linux. A mistake could make your operating system and data within inaccessible. The most critical aspect of configuring and compiling the kernel is the preparation beforehand - let's get started and you'll see what i mean.


Warmup
Before you even think about attempting it, make sure you know the make and specifications of your hardware and peripherals. Writing a comprehensive list of all your hardware isn't a bad idea at all. Once your satisfied you've got the skinny on your system, it's time to backup... especially if you've had a few too many beers and are doing this on impulse *sheepish grin*. It's also essential you have development tools already in place:




Roll Up Your Sleeves
If you have rpm kernel-source and headers, go ahead and install them. With tar.gz files, unpack them into /usr/src/linux-kernel version and make a symlink from /usr/src/linux to the actual kernel source tree /usr/src/linux-kernel version. In /usr/src/linux, you can either apply a patch - using the command
zcat /patch_location/ patchname.gz | patch -p0 -e
Type make mrproper which cleans up the kernel source tree. To initiate the kernel configuring stage proper, type make xconfig, make menuconfig or the text-based make config. I heartily recommend make xconfig. This stage is where you design/optimize the kernel for your particular system and computing needs. With each kernel feature, you will be presented with a y for "yes-i need this feature", n for no-"i don't need this feature or my system doesn't support this feature" and sometimes an m for modular. It's generally recommended one makes a kernel as modular as possible. This way, instead of having the software for a device always in memory, the module in question is loaded only when the device's services are requested.


    Kernel Configuring Tips:
  • If you have an AMD processor, select the Pentium or Pentium Pro option.
  • If you have a system greater than a 386, select no to math emulation.
  • Networking support
    If you want to connect with SLIP, PPP, term, and so on to dial up for internet access, you need to say yes. Even if your system isn't connected to a real network, the X window system and other packages need networking support.
  • Say yes to TCP/IP networking.
  • Standard (minix) - Minix filesystems is as outdated as Foghat, but a few rescue disks use it which may or may not be useful to you.
  • ISO9660 - Which entails most CD-ROMs. If you want to use your cdrom with Linux, it's a good idea to say yes and compile it with the kernel.



Double Check Your Configuration
Finished configuring your kernel? Fire up your favorite text editor and view the .config file in your current directory. The .config file was created when you executed the make xconfig command and documents your selections among other more esoteric settings. If you see something you dont want, reconfigure the kernel as described or edit the file if you know your stuff. Now, still from the /usr/src/linux directory run make dep; make clean from the command line prompt which as you guessed, runs make dep and make clean consecutively. Keep an eye out for errors. If you hear sirens or see smoke coming out of your box, things aren't copeseptic.


Compile the Kernel
Time to compile the kernel source. Type make bzImage and relax. Depending on the size of the kernel and brawn of your particular system, you may have enough time to watch the football double header or do a load of laundry. Once this is complete and there are no errors, cd over to /usr/src/linux/arch/i386/boot and and confirm there is the kernel executable file called bzImage is there. Copy bzImage to the /boot directory.


Let LILO in on it
It's important that we now alter LILO to reflect the changes we made. Open lilo.conf found in the /etc directory and create a new section for the newly configured kernel. We won't abandon the old kernel because we may need to use it in case our new kernel panics. The easiest way is to mimic the original entry, and change the name of the image to /boot/bzImage and the label of the old kernel image to something reasonable like linux.save or whatever.
Here's what lilo.conf should look like:
boot=/dev/hda
map=/boot/boot.b
prompt
timeout=30
image=/boot/bzImage
	label=Linux
	root=/dev/hda1
	read-only
image=/boot/vmlinuz-2.4.0-0.21
	label=linux.save
	root=/dev/hda1
	read-only



Now, at bootup, press the TAB button and you will be presented with a choice. But please, do NOT bootup yet! The kernel you just compiled and the old kernel, which is linux.save in this instance. Once you've made these changes to lilo.conf, exit the vim and type /sbin/lilo -v to seal the deal.


Make Your Modules
It's time to create the module executables and install them. Mosey on down to /lib/modules street and mv the old kernel module versions to a name that's easily identifiable-say 2.2.14.save. After your done that, enter make modules; make modules_install at the prompt, and visit your new modules in /lib/modules/kernel version number. Type /sbin/depmod -a which in essence instructs the kernel to load the modules in a set order.


Gut Check Time!
Time to reboot your system. If there are any failures during the boot up process, you'll need to fine tune the kernel further. The text might whirl by fast, so us the Pause/Break button to slow the text so you can jot the error down. If you get an outright kernel panic, reboot and at the LILO prompt and select the old kernel. See, it was a good idea to save the old image!