Linux Today: Linux News On Internet Time.

More on LinuxToday Compiling the Kernel: Part 2

Jun 05, 2000, 11:12 (0 Talkback[s])
(Other stories by Tom Dominico)

WEBINAR: On-demand Event

Replace Oracle with the NoSQL Engagement Database: Why and how leading companies are making the switch REGISTER >

"Last week, we discussed the basics of kernel compilation: what the kernel is, why you might want to compile one, and resources for more specific help. By popular request, we are pleased to present a second installment of the series, in which we'll provide our own step-by-step guide to actually performing the necessary configuration and compilation. Our goal will be to get you up and running as painlessly as possible."

"The first step, naturally, is to download the kernel source. Depending on your distribution, this procedure may vary. For my Debian system, getting the kernel source is as simple as "apt-get install kernel-source-2.2.15" (or whatever version you want to use). The traditional way to get the source is by visiting ftp.(your-country-abbreviation), and then choosing the appropriate version. You'll probably want to stick with the stable kernel series, the latest of which is 2.2.15 as of this writing. You'll notice that there are two different types of kernel packages: one that ends with .gz, and one that ends with .bz2. This indicates the type of compression that was used. Bzip2 does a better job of compression, so you'll probably want to download the .bz2 package, but you will need the bzip2 utilities installed to extract it. Or, you can simply get the .gz package and use gzip. When in doubt, use gzip; although bzip2 is increasing in popularity, it may not have been installed with your distribution."

"Now that you've got the source, it's time to extract it. If you used your distribution's packaging system, it's probably already been extracted for you. At any rate, you'll want to become root by typing "su" at the command line, then your root password, and head to the /usr/src directory by typing "cd /usr/src". You may already have the current linux source there, in /usr/src/linux. If you've got the disk space, you should probably keep it around, just in case. Rename the directory to reflect its version number (for example, "mv linux linux-2.2.12"). Move the new kernel to the /usr/src directory. Now, unpack your kernel if you downloaded it by hand. For gzipped files, use "tar -zxvf (filename)". For bzipped files, use "tar -Ixvf (filename)". This will create a new "linux" directory, containing the kernel source in all its glory. If you used your distribution's packaging system instead of downloading the kernel by hand, it may have extracted the source into a directory labeled with the kernel version. In that case, you can either create a symlink (using the "ln" command) from that directory to /usr/src/linux, or rename it."

Complete Story

Related Stories: