The Very Verbose Guide to Updating and Compiling Your Debian Kernel

If you are reading this, I assume you already know what the Linux kernel is and why you may want to update it. However, if you are accidentally reading this walkthrough, just happen to be running Linux, and have no idea what the kernel is or why you would want to update it, the next two paragraphs are for you (if you are looking instead into a less verbose and more generic way of updating your kernel on any Linux distro, read here). In a neophyte nutshell, the Linux kernel is the brain of the Linux system. It tells your system which file systems, hardware, protocols, etc. are supported. There is a lot more to it than that, of course, but I think that diminutive description will suffice for now.

MY THANKS
Before we begin, I would like to sincerely thank all of the people who provided me with valuable feedback regarding my last article “The Very Verbose Debian 3.0 Installation Walkthrough“. I am grateful for your insights, corrections and comments. Also, I would like to apologize for the lateness of this article. My life has taken many twists and unforeseen paths during the last few months. I’m glad to finally feel back on track.


INTRODUCTION AND EXPECTATIONS


So why would you want to mess with the kernel? Well, all the people (who are a step beyond mere mortals and a lot smarter than I am) that work on the Linux kernel are constantly adding support for new hardware, new technologies, new bug fixes, and making myriad other improvements to the Linux kernel. By upgrading our kernel, we increase the abilities and support of our Linux system. Also, a computer has not been built, that I know of anyway, which utilizes all the hardware and other support available in the Linux Kernel. Therefore, why carry around support for a lot of things you don’t need if you don’t have to.


In this walkthrough, I will attempt to describe the process of updating and compiling a Linux kernel under Debian. I will try to explain the necessary steps in a way that will dispel all mystery and fear. My hope is that somebody new to Linux will be able to go through this comfortably and end up with an updated system when they are done.


As much as I want to make this a painless process, and one devoid of failure, one thing I cannot provide is a detailed description of your hardware or the things you want your system to support. Therefore, I am focusing on the three most requested topics, sound, journaling filesystems, and the ability to burn CDs. However, I feel I am giving enough detail that you shouldn’t have any problems with the rest of the configuration process and enabling things like USB.


Knowing what hardware is in your system is absolutely necessary if you want to optimize your kernel specifically for the hardware you have. For example, to compile in support for your sound card, you must know what kind of sound card you have. Often times you can find this information in the manuals that came with your computer, from Windows Device Manager (if you run Windows), or from the manufacturer’s web site if you bought your computer from a company such as Gateway, HP or Dell.


Please don’t be completely discouraged if you don’t know what hardware you have in your machine. While you may be out of luck as far as configuring the kernel for your motherboard’s specific chipset, there are still many improvements you can make to your system, such as support for the EXT3 journaling file system, which will be worth while.


One more thing before we begin. Parts of what I will present in this walkthrough are applicable to all Linux distributions, while other parts are specific to Debian and distributions, such as Libranet and Xandros, which are derived from Debian. While I will not cover the non-Debian way of updating and compiling the kernel, the configuration part of the article is applicable to all versions of Linux (as long as they are running X that is).


Okay. Let’s update our kernel.


DOWNLOADING A NEW KERNEL


If you read and followed “The Very Verbose Debian 3.0 Installation Walkthrough”, you should now have the 2.2.20 kernel installed on your system. This kernel lacks support for things like USB and the EXT3 file system. If you have a very large drive and have ever had to sit through your next three birthdays waiting for Linux to check your partitions after an unclean shutdown, you will love journaling filesystems like EXT3 and definitely want to have support for them in your kernel.


In this walkthrough, we are going to upgrade our kernel to version 2.4.20 (which was the latest stable kernel when I started writing this. Please feel free to grab a later kernel you want to). In order to do so, we need to download the source for that kernel. To download the kernel source, you can use any of your favorite methods (wget, ncftp, etc.), however, in this tutorial I am going to download the 2.4.20 kernel via Mozilla since we should already have it installed and most people are familiar with downloading files through a web browser.


In order to download the latest kernel (2.4.20), launch Mozilla (or your favorite web browser) and go to The Linux Kernel Archives (http://www.kernel.org). On the main page you will see a box under the title, which has links to an HTTP server, an FTP server, and an RSYNC server. Below this box, you will see the line, “The latest stable version of the Linux kernel is 2.4.20” (or whatever it currently happens to be), with “2.4.20” highlighted as a link. For this tutorial, you do not want to download from this link since it is just a patch. However, this information is important since it will tell you what the latest kernel available is, so when you go to the correct download area, you will know which kernel to download; assuming you want the latest one.


To go to the download area where you can obtain the full updated kernel, click on the HTTP link in the gray box at the top of the page.


You should now be on a page titled, “The Public Linux Archive – (As if there were a private one you could get to)”. There is another gray box at the top of this page. Please click the first link listed (http://www.kernel.org/pub/linux).


You should now be on page titled, “Index of /pub/linux”. In the directory structure on this page, click on the “kernel” link.


Now you should be on a page titled, “Index of /pub/linux/kernel”. In the directory structure shown on this page, click on the “v2.4/” link.


You should now be on a page titled, “Index of /pub/linux/kernel/v2.4”. This is where we will find the kernel. There are oodles of files listed in the directory on this page. You want to make sure to download the file called “linux-2.4.20.tar.gz”. You will notice that there is also a bz2 and a bz2.sign file. Bz2 is another compression format, but the utility to uncompress this file is not loaded on your Debian machine by default (although it wouldn’t take much effort to install it using apt). The tar utility, however, is already installed on your Debian machine, so I have chosen to download the linux-2.4.20.tar.gz file for this walkthrough. Download the file and save it in your home directory (/home/).


PREPARING THE 2.4.20 KERNEL’S SOURCE


In the last section, we downloaded the kernel source code. Currently it is contained in one compressed file (linux-2.4.20.tar.gz) in you home directory. In this section, we will move this source code to the correct location and uncompress it.


In order to compile the new kernel, we need to place it in the /usr/src directory. You may be asking yourself, “If I wanted the kernel source file in the /usr/src directory, why didn’t I save it there in the first place?” The answer is that you didn’t have rights to do so since you were logged in as a normal user (at least I hope you were logged in as a normal user and not as root).


I don’t recommend surfing the web as the root user. Your computer is not going to explode or anything like that, but it is risky if you do everything as root. Therefore, I suggest downloading files off the internet as a regular user and saving them to your home directory. Once your download is complete, you can use the “su” command to log in as root and move the files into more secure locations if necessary.


If you are familiar with Linux (don’t worry if you are not, I’ll help you more in a minute), login as root and move the “linux-2.4.20.tar.gz” file from your home directory, where you saved it, to the “/usr/src” directory.


Next, uncompress the file by entering “tar xvzf linux-2.4.20.tar.gz” at the command line. This will create a directory called “linux-2.4.20” inside the “/usr/src” directory.


Next, create a symbolic link named “linux”, which points to the “linux-2.4.20” directory by entering “ln -s linux-2.4.20 linux” at the command line. If this symbolic link already exists, delete it and create it again as described above.


You may now skip over the rest of this section and go to the “APT FILES NECESSARY TO CONFIGURE AND COMPILE YOUR KERNEL” section.


If the above four paragraphs were confusing to you, here are the same steps in almost mind numbing detail.


In order to move the “linux-2.4.20.tar.gz” file to the correct location, follow these steps:


Step 1: (Open a terminal window)
If you followed my installation document, you will be running the WindowMaker window manager. If you are, then right click on the desktop to bring up the menu, click on XShells, and then click on XTerm to bring up a terminal window. If you are running a different window manager, use whatever method your window manager requires in order to launch a terminal window.


Step 2: (Go to the directory where you downloaded the “linux-2.4.20.tar.gz” kernel file)
Make sure you are in your “/home/” directory (or wherever you saved the linux-2.4.20.tar.gz file). To do this, Enter “pwd” at the command line. pwd will tell you which directory you are in. If pwd returns something other than your home directory, enter “cd /home/” at the command line to get to your home directory.


Step 3: (Log in as root using “su”)
Now you need to log in as root by entering “su” at the command line if you haven’t already. Enter the root user’s password when prompted.


Step 4: (Move the “linux-2.4.20.tar.gz” file to the “/usr/src” directory)
Now enter “mv linux-2.4.20.tar.gz /usr/src” at the command line. This will move the “linux-2.4.20.tar.gz” file from your home directory to the “/usr/src” directory. If you get a “Öno such file or directory” error, you either did not download the kernel file, or you are not in the directory you downloaded the file to. Go to the directory you downloaded the kernel source in to and try this step again.


Step 5: (Check the /usr/src directory)
Change to the “/usr/src” directory by entering “cd /usr/src” at the command line. At the command prompt, enter the “ls -l” command. As you probably know, the “ls” command shows you a list of all the files in the current directory. The “-l” switch after “ls” shows you more information than when you only type “ls” by itself. It shows you the “long” format; hence the ‘-l’. You should see the “linux-2.4.20.tar.gz” file we just copied into this directory. It should be the only file there. If this is the case, skip the rest of this section and go to Step 6.


It is possible that the directory has other files other than the “linux-2.4.20.tar.gz” file we just copied here. If you have the source code for an old kernel on your machine, it will be in this directory as well. Also, you may have a symbolic link pointing to these old kernel sources.


Before I go on, let me explain what a symbolic link is. A symbolic link is a link or alias that points to another file or directory. If you are familiar with Windows, a symbolic link is similar to a Shortcut. We will create a symbolic link in Step 6, so if they still aren’t clear, hopefully they will be after you make one.


Now, please look at the other files in the “/usr/src” directory. Is there one named “linux”? If not, you may skip the rest of this section and go to Step 6. If there is an item in this directory named “linux”, check to see whether it is a symbolic link or a regular directory. You can determine this by using the “ls -l” command and looking at the output. Enter “ls -l” at the command line. The output may be something like this (only formatted better).


lrwxrwxrwx 1 root src 12 Oct 31 13:03 linux -> linux-2.4.18
drwxr-xr-x 14 573 573 4096 Aug 2 18:39 linux-2.4.18
-rw——- 1 clinton clinton 32219641 Oct 30 14:40 linux-2.4.20.tar.gz

Let me use the first file listed as an example to explain where you need to look. The first part “lrwxrwxrwx” shows the file type and permissions of this file.


The first character, ‘l’ indicates that this file is a symbolic link. Directories, on the other hand, are indicated by a ‘d’ in this position instead of an ‘l’. Regular files are indicated by a ‘-‘ in the first position (there are some other characters that can appear here as well, but they are beyond the scope of this document). The other characters are referring to file permissions for the user, group, and other users respectively. I am going to ignore these for now.


I am also going to skip by the entire middle section of the directory listing and move to the end, which is the name of the file. If you look at the three files listed above, you will notice that the top one shows the name of the file “linux”, followed by an “->” and then “linux-2.4.18. This means that the file “linux” is a symbolic link that points (hence the nice arrow [“->”] motif) to “linux-2.4.18”. If you look at linux-2.4.18, you will see that it is a directory (notice the very first character of the “linux-2.4.18” line is a ‘d’ signifying a directory).


Once you have determined that you have a “linux” file in the “/usr/src” directory, do one of the following.


If the “linux” file is a symbolic link, delete it by entering “rm linux” at the command line.


If the “linux” file is a directory, rename it by entering “mv linux linux.old.one” at the command line.


You should now be ready to continue.


Step 6: (Uncompress the “linux-2.4.20.tar.gz” file)
Now we need to uncompress the linux-2.4.20.tar.gz file so we can access the kernel source. To do this, enter “tar xvzf linux-2.4.20.tar.gz” at the command prompt. It will take a while to uncompress the “linux-2.4.20.tar.gz” file. When it is done, you should be back at the command prompt (‘#’) again.


Step 7: (Creating a symbolic link called “linux”, which points to “linux-2.4.20”)
Finally, we can create a symbolic link called “linux” that will point to our new kernel source code, which is located in the “linux-2.4.20” directory. Enter “ln -s linux-2.4.20 linux” at the command line to create this symbolic link. If you type “ls -l” at the prompt, you should now see a symbolic link called “linux” that is pointing to the “linux-2.4.20” directory (or the directory for whichever version of the kernel you decided to download).


APT FILES NECESSARY TO CONFIGURE AND COMPILE YOUR KERNEL


In order to configure and compile our kernel, we are going to need to use apt (or Synaptic if you prefer) to download a few things.


Enter the following command, while logged in as root, to download what we need (or select each of the items in this list from within Synaptic and install them that way):


apt-get install tk8.2 make gcc bin86 libc6-dev kernel-package


In this tutorial, I will be using the graphical kernel configuration tool from within X. If you would rather use the command line configuration tool, you will need to replace “tk8.2” with “libncurses5-dev” in the command above (or you can install both of them and do it either way you want to; depending on your mood).


After everything is downloaded and installed, a screen titled “Configuring Binutils” will be displayed. It is warning saying that this version of binutils will not work with some kernels. Since we are using the latest stable kernel, we will not have any problems. Just press enter to continue.



STARTING THE LINUX KERNEL CONFIGURATION TOOL


Assuming you are still in the “/usr/src” directory and have followed the instructions above, enter “cd linux” to change directories into the linux directory (which you may recall is a symbolic link to the linux-2.4.20 directory).


Once you are in the “/usr/src/linux” directory, you are ready to start the kernel configuration tool. Enter “make xconfig” at the command line to start the Linux Kernel Configuration tool.


If you would rather use the command line version of this tool instead of a graphical window, you need to enter “make menuconfig” at the command prompt. I’m not going to cover this tool in this walkthrough, but I think you should be able to follow along since the two tools are somewhat similar.


You should now be looking at a gray screen with a lot of buttons on it. If you received an error at the command line, and the tool didn’t launch, open up another terminal window and enter “xhost +” as your regular user in order to allow other users (in this case root) to launch graphical applications from within your X environment. Once you have done this, enter “make xconfig” as root again to launch the Linux Kernel Configuration tool.


If the Linux Kernel Configuration tool still won’t start, and you are still getting an error, make sure you installed all the necessary tools mentioned above. These are:


tk8.2, make, gcc, bin86, libc6-dev, kernel-package, libncurses5-dev (only necessary if you want to use the command line configuration tool)


If you have been able to successfully launch the Linux Kernel Configuration tool, we can continue to the next section.

CONFIGURING THE LINUX KERNEL


You should now have the Linux Kernel Configuration tool open. Before we begin, I recommend moving the Linux Kernel Configuration window up to the top of your screen. We will be opening up many child windows during the process of configuring the kernel, and those windows will pop up in relation to the main window (the one with all the buttons on it). If you place the main window towards the bottom of the screen, many of the child windows will appear mostly off the screen and you will forever be dragging them up so you can see them. You can save yourself a lot of clicking, dragging, and cursing by moving the main Linux Kernel Configuration window to the top of the screen.


Configuring the kernel sounds like a very scary task to some, but in reality, all you are doing is answering a whole bunch of multiple choice questions. For the most part, the Linux Kernel Configuration tool will ask you if you want to load support for something, and you will answer ‘Y’ (Yes) to load support for that item, ‘N’ (No) to not load support for that item, and ‘M’ (Module) to load support for that item as a module.


The benefit of loading things as modules is that the kernel is smaller (and probably faster) and you can load and unload that module at will without having to recompile your kernel. For the first time, however, I recommend selecting ‘Y’ for things you want to support. You can read about how to use modules later; once you are familiar and comfortable with recompiling your kernel.


Now, there is really no way for me to walk through every setting of the Linux kernel, since everyone’s hardware is different. However, the Linux Kernel Configuration tool has a lot of help available. In fact, every multiple choice line of the Linux Kernel Configuration tool has a help button associated with it, and there is almost always good information in the help dialogs. I highly recommend reading the help dialogs for each line as you go through the kernel. It will help you make the right choices for your hardware, and also help you get familiar with the services the kernel provides.


Code maturity level options:
To see an example of the Linux Kernel Configuration tool and how it works, including the help dialogs, click on the “Code maturity level options” button, which is at the top left corner of the Linux Kernel Configuration window. You will notice that a new dialog window appears. In the case of the “Code maturity level options” dialog, there is only one question you need to answer, “Prompt for development and/or incomplete code/drivers”.


Before we decide whether or not we want support for this item in our kernel, let’s look at the help dialog. To do so, click on the “Help” button to the right of the “Prompt for development and/or incomplete code/drivers” text.


After you have read the help dialog, go back to the last paragraph and look at the first sentence again. It reads, “Unless you intend to help test and develop a feature or driver that falls into this category, or you have a situation that requires using these features, you should probably say N here.” Many of the helps that are available in the Linux Kernel Configuration tool will explain what you are currently looking at and also suggest answers to you. I think this is very useful for those who are not familiar with compiling their own kernel. If you are unsure about a particular line item, I recommend following the suggestion offered by the help dialog. If no suggestion is given, the default value is usually a safe bet.


Just in case anybody has a question about this, by enabling the “Prompt for development and/or incomplete code/drivers”, you enable sections in the Linux Kernel Configuration utility which are considered experimental or still a bit unstable. Firewire support is an example of this. If you look at the main window of the Linux Kernel Configuration tool, you will notice that there is a button for Firewire support that is disabled (meaning you can’t click on it). If you were to select ‘Y’ for “Prompt for development and/or incomplete code/drivers” and then look at the main window again, you would see that the Firewire support button is now enabled. I don’t recommend enabling this for now. Wait until you are more familiar with configuring your kernel.


Now that we know what the “Prompt for development and/or incomplete code/drivers” line item is, we can safely select ‘N’ (which is the default) at the left side of the line. You will also notice that there are only options for Y (Yes) and N (No). M (Module) is missing. If any of the three choices (Y, N, or M) are unavailable for a specific kernel option, it will not be displayed.


Since there are no more kernel settings on this dialog, click the “Next” button at the bottom of the dialog to go to the next dialog in the list. You could also click the “Main Menu” button and then select the next button below the “Code maturity level options” button, which is the “Loadable module support” button, but it is easier in my opinion to simply click the “Next” button when you are done with each dialog, and move through the configuration process in a linear fashion.


Loadable Module Support:
On the “Loadable module support” dialog, you will notice that there are three kernel options you need to set. Please read the descriptions of all three options and then select ‘Y’ for each of them. Press the “Next” button when you are finished.


Processor Type and Features:
This is the point of the kernel configuration where it gets specific to your hardware. The only reason I am bringing this dialog up is to show the drop down lists that also exist in the Linux Kernel Configuration tool, and help you out with a couple of the more cryptic options.


The very first item on this dialog is the “Processor family” option. You will notice, however, that instead of the standard Y – M – N choice that you have previously seen, you are presented with a button instead (I believe the default, and therefore the title currently displayed on the button, is “Pentium-III/Celeron (Coppermine). Click this button and select your computers processor from the list. If you don’t know what kind of processor you have, the default will work, but it won’t be optimized for your machine. My machine, for example, uses an AMD Athlon processor, so I will select the line that says “Athlon/Duron/K7” from the drop down list. If you don’t know what processor you have, 386 is a safe, but un-optimized choice.


Please read the help dialogs available for each of the remaining options and chose the appropriate Y (Yes), N (No), or (M) Module settings for each. When you are finished, press the “Next” button. Also notice that some of the options you mill run into are not checkboxes or drop-down lists, but are actually buttons that bring up new windows. Make sure you click on all of these. Also, if you always click the “Next” button at the bottom of each window, you are guaranteed to see all aspects of the kernel. If you don’t do this, you might miss something.


I will help configure CD-R/RW drives, Journaling file systems, and sound cards in a minute, but in the meantime, continue the procedure of reading the help for each line, making the appropriate selection (Y – N – or M), and selecting “Next” at the bottom of each window until you have gone completely through the kernel configuration. This will take some time, but it is well worth it.


I wish I could offer more help during this process, but I don’t know your hardware, nor do I know what specifically you want to do with your machine. Therefore, I leave you in the competent hands of the help screens.


I would like to suggest that you adhere to the following guidelines, at least until you become familiar and comfortable with the Linux kernel. Often times, people think, “I’ll just install support for everything”. This is a very bad idea. Only compile support in for things you know you want or need. Also, if you don’t know what something is, just accept the default. If you have questions, please use a good internet search engine, such as Google, to look for help. You may also email me if you’d like and I will help out where I can.


Please go through the entire kernel once before continuing.



CONFIGURING YOUR KERNEL FOR SOUND


Now that you have gone through the entire kernel once, let’s go back and configure support for sound, journaling file systems, and CD burners. We will start with sound.


Click on the “Sound” button, which is the third button down in the third column (it may be in a different location if you are using a different version of the kernel, but it should be labeled “Sound” still). This will bring up the “Sound” window.


The first item on this window says, “Sound Card Support”. You need to set this to ‘Y’. Then, you need to select the correct sound card from the list of sound cards presented here. For example, I have a Sound Blaster Live! Value card. To enable support for this card, I want to set the “Creative SBLive! (EMU10K1)” option to ‘Y’.


Another popular card is the “Creative Ensoniq AudioPCI 97 (ES1371)”. If you aren’t sure what card you have, or if your card is built into your motherboard, try setting this option to ‘Y’. More often than not your sound card will work with this setting.


If you know which card you have, set the appropriate option to ‘Y’ and set everything else to ‘N’ (except for the first option, “Sound Card Support” of course). When you are done, click on the “Main Menu” button.

CONFIGURING DEBIAN TO SUPPORT CD BURNERS


Next, let’s configure your machine to support a CD burner. Linux only supports SCSI CD burners, so if you have one, you should already be able to burn CDs under Linux. Most people, however, own IDE CD burners and by default these are not supported per se under Linux.


Fortunately, the Linux kernel can be configured to support your IDE CD burner through SCSI emulation. To set this up, we will need to go into a couple of different areas in the Linux Kernel Configuration utility.


The first area we need to configure is the “ATA/IDE/MFM/RLL Support” area. From the main configuration screen, click on the button labeled “ATA/IDE/MFM/RLL Support”. This will bring up a Window with only two items on it. The second item is a button labeled “IDE, ATA and ATAPI Block Devices”. Click on this to bring up a new window.


You should now be on the “IDE, ATA and ATAPI Block Devices” window. There are several different ways to configure your machine to support your IDE CD burner as a SCSI device, however, for the sake of simplicity; I have chosen to do it as described below.


First, you need to disable support in your kernel for IDE CD-ROM drives. Do this by setting the “Include IDE/ATAPI CDROM Support” option to ‘N’.


Next, you need to enable SCSI emulation support by setting “SCSI Emulation” to ‘Y’.


NOTE: For those who like to complain that I didn’t do something a certain way that you happen to like, I know this may not the preferred way to add support for a CD burner, but it works and it is simple (after all, this article is geared towards new users). Once you are comfortable with configuring your kernel, feel free to add support for IDE CDROMs back into the kernel and specify which CDROM drives should be considered SCSI via the ‘append=”hdx=ide-scsi’ in lilo.conf. I’m not going to cover that method in this article.


Click the ‘OK’ button to close this window, and then click on the “Main Menu” button of the “ATA/IDE/MFM/RLL Support” to close it as well. You should now be back at the main menu.


Next, click on the “SCSI Support” button on the main menu.


On the “SCSI Support” window, set the following options to ‘Y’:
SCSI Support
SCSI Disk Support
SCSI CD-ROM Support
SCSI Generic Support
Enable Extra Checks in New Queuing Code


Set everything else to ‘N’.


NOTE: It is usually difficult for new users to track down SCSI issues, and you usually don’t need to when you are only using SCSI emulation as we are here. If you would like to support SCSI error logging (for fun or because you are having a problem), then you can also enable the following options:


Verbose SCSI Error Reporting
SCSI Logging Facility


That’s it. Click on the “Main Menu” button to close the SCSI window.


ENABLING SUPPORT FOR THE EXT3 FILE SYSTEM (YOU WANT TO DO THIS)


Finally, let’s enable support for the EXT3 file system. There are other journaling file systems supported by the Linux kernel as well, such as JFS and ReiserFS, but I am only going to focus on EXT3 in this article. EXT3 is very stable and if something does go wrong, you already have the tools to work with and make corrections to the file system since it is compatible with the standard EXT2 filesystem.


To enable EXT3 support, from the main configuration window, click on the “File Systems” button. This will bring up the File Systems window. Scroll down to the “EXT3 Jounaling File System Support” option and set it to ‘Y’. Leave everything else on this window at its default (unless there are other filesystems you want to use; such as vfat, which allows you to mount Windows FAT32 partitions).


When you set the “EXT3 Jounaling File System Support” option to ‘Y’, the item right below in, EXT3 debugging, will become enabled. Leave it at the default ‘N’.


The sound and SCSI support are now configured for us (well, except for changing the /dev/cdrom device to point to the right place, which we’ll do later), but we are not quite finished with the EXT3 support yet. However, we must compile the kernel before going on with those tasks.


Click the “Main Menu” button to close this window.


SAVING THE KERNEL CONFIGUATION AND COMPILING


Now we are ready to compile the kernel. Before we do that, however, I would like to mention one thing. If you have multiple machines that you want to install the same kernel on (This won’t work well if the hardware on the machines isn’t the same) click the “Store Configuration to File” button. This will save all the changes you just made to a file. You can then copy that file to your other machines, and when you open the Linux Kernel Configuration utility on those machines, you just have to click on the “Load Configuration from File” button and open your saved kernel file. This will save you from having to go through the configuration process on each machine.


Now, let’s compile the kernel. From the main Linux Kernel Configuration window, click on the button titled “Save and Exit”. It will pop up a window telling you to check the top level makefile and run make dep. You don’t have to do either of these things, so just click the “OK” button. You should now be back at the command prompt.


At the command prompt, type “pwd” to print the working directory. It should return “/usr/src/linux” (if it returns anything else, type “cd /usr/src/linux” to go to the directory that contains your kernel’s source code).


Once you are in this directory, type the following two commands:
make-kpkg clean
make-kpkg –revision=786:MyKernel2.4.20 kernel_image


The second of these commands is where the actual compiling takes place. On my AMD Athlon 1800+ machine, the compile process takes around ten minutes to finish. On one of my older machines, it can take over an hour (on a 486, you’re probably looking at a few days). If you have an older machine, go eat lunch and enjoy a good comedy movie. The compilation should be finished by the time you come back. You probably need a break anyway.


If you really want to understand the deep crevices of what is going on here, you can read the documentation that is located in /usr/doc/kernel-package/ for more information. In a nutshell, however, what you are doing is creating a .deb file that we are going to install in exactly the same way we install programs; using the dpkg utility. This file we are generating will automatically handle the system configuration tasks for us that the poor saps that use other Linux distributions have to do manually. This is generally a good thing.


INSTALLING THE NEW KERNEL


Once you have finished lunch and a movie, your machine should be finished compiling the kernel and you should be back at a prompt. You should also have a new file in your /usr/src directory.


Let’s go there now by typing “cd /usr/src” at the command line. If you type “ls -l” at the command prompt, assuming you didn’t receive any compile errors, you should see a file called “kernel-image-2.4.20_MyKernel2.4.20.deb”; or something like that.


Now we need to install the kernel, just as we would any .deb file, by using the dpkg utility. Type “dpkg -i kernel-image-2.4.20_MyKernel2.4.20.deb” (or the name of the file if yours is different) at the command prompt and press Enter.


Once the installation is finished, you will be prompted to create a boot floppy. I suggest you do so, but you don’t have to.


Next, you will be prompted to install a boot block using the existing /etc/lilo.conf. If you don’t say yes here you won’t be able to boot your machine into your new kernel (unless you said yes to the floppy question, but then you can only boot with that floppy). Regardless of which you choose, make sure you say “yes” to either or both questions; otherwise you will be left without the ability to boot your shiny new 2.4.20 Linux machine.


Once this process has finished, you need to reboot your machine. Upon reboot, type “dmesg” and look at the output. Look for any errors. You should also notice (if you can read cryptic Linux messages) that your sound card has been recognized. If you see a problem, such as you picked the wrong sound card, then you will need to make the change in the kernel and try again. If that happens, see the last section of this article.

SETTING UP YOUR MACHINE TO USE THE EXT3 JOURNALING FILE SYSTEM


Remember a while back when I said we weren’t done with the EXT3 stuff yet? Well, it’s now time to remedy that situation. Before beginning, you will need to have a text editor such as vim, nano, pico, or any of the graphical ones available. Please pick one that you like and then let’s continue.


First, you will need to know which partitions you have on your machine. If you don’t remember, you can type the command “df” at the command line, and it should list all the partitions mounted on your machine. Here is an example of df’s output:



Filesystem Mounted on
/dev/hda1 . . . /
/dev/hda3 . . . /usr
/dev/hda5 . . . /var
/dev/hda6 . . . /home


Now you need to use this information in the following command. You can either type:
“/sbin/tune2fs -j /dev/hdxx” (where x is the drive and partition number, such as /dev/hda1, or /dev/hdb3) at the command line for each partition you have, or you can do it all at once using the following script command (don’t type the ‘#’ or ‘>’, those are the prompts. Also, press after each line, and make sure your devices are separated by a space):


# for each in /dev/hda1 /dev/hda3 /dev/hda5 /dev/hda6
> do
> /sbin/tune2fs -j $each
> done


If you get an error, you either didn’t type it correctly, or you have put an invalid device in the list. Make the appropriate corrections and retype the command.


This will convert all of your partitions from ext2 to ext3. Once this is done, you need to tell Linux to mount all your partitions as ext3 partitions. This is where we need the text editor.


As root, open the file /etc/fstab. Wherever you see the word “ext2”, change it to “ext3”. Once you are finished, save the file and exit the editor.


Now, we have to do one more thing before we reboot again (you could manually unmount and remount all your partitions into ext3, but it’s probably easier to just have you reboot again and have Linux automatically mount everything using ext3 for you).


I briefly hinted at this before, but we need to fix our /mnt/cdrom device. It is currently pointing somewhere like /dev/hdb, however since we made our CDs emulate SCSI, our CDROM doesn’t exist there any more. We need to fix the /dev/cdrom link.


To do this, you first need to know where to change the /dev/cdrom link to point to. Usually, it will be /dev/scd0, but let’s make sure. Place a data CD in the CDROM drive and type:
“Mount /dev/scd0 /cdrom”


If all goes well, you should be able to type “ls /cdrom” at the command prompt and get a directory listing of your CD. If not, and especially if you have more than one CD device in your computer, then try other devices, such as /dev/scd1, /dev/scd2, etc.


Once you know which drive you want to be the default CD drive, change the /dev/cdrom symbolic link to point at it (you probably remember symbolic links from our discussion on where to save the Linux kernel source code. /dev/cdrom is just a symbolic link that points to a device on your computer). To demonstrate how to do this, I am going to use my system, on which the default CD drive is on /dev/scd0. To change the /dev/cdrom link to point to the right device, type these commands at the command line:
“rm /dev/cdrom” (this removes the current, incorrect /dev/cdrom link)
“ln -s /dev/scd0 /dev/cdrom” (this will create a new /dev/cdrom link that points to the correct device)


Now you should be done. To make sure, at the command prompt, type “umount /cdrom” to unmount the CD you mounted a few minutes ago. Next, you should type “mount /cdrom” at the command prompt. You should now be able to type “ls /cdrom” and get a directory listing of your CD. If so, you have done everything correctly. If not, go back and check your settings again. Also, it should be there already, but if something isn’t working, type “cat /etc/fstab” at the command prompt and make sure your fstab file contains a line that begins “/dev/cdrom /cdrom”. If not, you will need to add the following line to your fstab file:


/dev/acd0c              /cdrom          cd9660  ro,noauto       0       0


If everything is working, it is time to reboot. If you have placed a bootable CD in your drive during this process, remove it before rebooting.


WHAT IF SOMETHING GOES WRONG?


Seeing as this is probably the first time you have compiled your kernel, it is possible, although entirely unwanted, that you will make a mistake (such as including the wrong sound card in the kernel).


There are a few things that you need to do before trying to recompile your kernel again. First, you need to delete or rename the .deb file in your /usr/src directory (or change the name you give it during the “make kpkg” steps listed earlier in the article).


Next, if you are attempting to recompile the same kernel version as before (for example, 2.4.20), you will need to rename or delete some things before you can recompile again. The nice thing is that during the “dpkg -i ” you will get a message telling you exactly what to delete or rename. When you get this message, open a new xterm window, delete or move the offending directory, hit CTRL+C to abort the “dpkg -i” process in the first xterm window, and then restart the “dpkg -i” again. Everything should go fine.


If there is one point that I want to emphasize in this article, it is to read everything; both this document and the help screens. Don’t guess; that will pretty much guarantee failure.


CONCLUSION


That is it. Hopefully you are a little more comfortable with obtaining, configuring and compiling your Linux kernel under Debian. I hope you have fun learning with Debian.


About the Author:
My name is Clinton De Young and I work as a Development Manager for a software company called Altiris. I am a native English speaker, and am fluent in Japanese. On the side I translate documents to and from Japanese and sometimes freelance with companies to write software for the Japanese market. In spite of all that, my family comes first. They are the most important people in my life.

59 Comments

  1. 2003-03-03 4:22 am
  2. 2003-03-03 5:09 am
  3. 2003-03-03 7:24 am
  4. 2003-03-03 8:47 am
  5. 2003-03-03 8:52 am
  6. 2003-03-03 9:13 am
  7. 2003-03-03 9:37 am
  8. 2003-03-03 9:57 am
  9. 2003-03-03 10:34 am
  10. 2003-03-03 11:26 am
  11. 2003-03-03 12:03 pm
  12. 2003-03-03 12:30 pm
  13. 2003-03-03 12:35 pm
  14. 2003-03-03 12:36 pm
  15. 2003-03-03 1:31 pm
  16. 2003-03-03 2:47 pm
  17. 2003-03-03 3:16 pm
  18. 2003-03-03 3:19 pm
  19. 2003-03-03 3:30 pm
  20. 2003-03-03 3:39 pm
  21. 2003-03-03 3:47 pm
  22. 2003-03-03 4:21 pm
  23. 2003-03-03 5:07 pm
  24. 2003-03-03 5:08 pm
  25. 2003-03-03 5:18 pm
  26. 2003-03-03 5:39 pm
  27. 2003-03-03 6:09 pm
  28. 2003-03-03 7:23 pm
  29. 2003-03-03 8:52 pm
  30. 2003-03-03 9:57 pm
  31. 2003-03-03 10:13 pm
  32. 2003-03-03 10:43 pm
  33. 2003-03-03 11:24 pm
  34. 2003-03-03 11:32 pm
  35. 2003-03-04 2:10 am
  36. 2003-03-04 2:17 am
  37. 2003-03-04 2:21 am
  38. 2003-03-04 4:41 am
  39. 2003-03-04 4:44 am
  40. 2003-03-04 5:31 am
  41. 2003-03-04 6:05 am
  42. 2003-03-04 6:44 am
  43. 2003-03-04 11:03 am
  44. 2003-03-04 2:18 pm
  45. 2003-03-04 4:46 pm
  46. 2003-03-04 5:04 pm
  47. 2003-03-04 11:28 pm
  48. 2003-03-04 11:52 pm
  49. 2003-03-05 8:14 am
  50. 2003-03-06 6:45 am
  51. 2003-03-06 6:07 pm
  52. 2003-03-06 6:13 pm
  53. 2003-03-06 6:19 pm
  54. 2003-03-09 4:46 am
  55. 2003-03-10 12:31 pm
  56. 2003-03-10 4:34 pm
  57. 2003-03-12 7:11 am
  58. 2003-03-12 2:14 pm