Super quick guide to compiling a kernel

This is the lazy man's guide to compiling a kernel. It's also quite dated, so one should probably google around for better ones.

I'm assuming that you've got a basic idea of what you do and just want a quick refresher.

NOTE: This is for the 2.4 kernel. This page is really dated, but I'm leaving it up for the moment.

Another good quick guide is Skylinux's, which he has given me permission to post here.

Quick note--if you're running RedHat then see my page on RedHat as it has a few oddities about it.

Anyway, this is not a detailed guide--this just quickly covers the steps.

So, first download the latest kernel source from At time of writing, the latest stable version is 2.4.10 which could be found at (I haven't put a link to it, since, as new kernels come out, it will soon be dated.) Or do it via ftp

ftp When it asks for a login name put
You'll then see a message that anonymous logons are ok and that you should send your email as password.
cd /pub/linux/kernel/v2.4 (or whatever version it is that you want
get (filename)
The filename will be something like linux-2.4.8.tar.gz or .bz2 depending upon your choice. (One thing here, in an xterm or console window, it's sometimes difficult to see the name of the file that you want. The hash command is optional--I use it because it produces hash marks as it downloads, giving me an idea of progress.

Do as much of this as you can as user. At some point, you will have to su to root, but as they say in the README, don't take root's name in vain. Keep going till you get permission denied. :)

I usually download it directly into /usr/src. Otherwise, just move the file once it's been downloaded. (I think this is where you have to su to root. We'll use linux-2.4.10.bz2 as our example.

mv linux-2.4.10.bz2 /usr/src/
Change into that directory
cd /usr/src
If you already have a working configuration, back it up--in that case there will be a directory called linux already there (again, this is aside from RedHat)

mv linux linux.bak

Untar the file you just downloaded--if it's a bz2 then
tar -jxvf linux-2.4.10.bz2
You now have a directory in /usr/src called linux
cd linux

Now you have a few choices. If you want to start from scratch then do

make mrproper

This will start you off with a totally fresh kernel. However, if you've saved a config file from a previous build, and have copied it into /usr/src/linux once you untarred the latest kernel, don't make mrproper, as it will lose your old configuration. Either way, the next step is to

make xconfig

That is one choice, and probably the easiest. It has help for most of the choices (the kernel howto mentioned above gives additional help.) The other choices are:

make config
make menuconfig
make oldconfig

make config gives you a menu that offers help (type ? whenever it's listed as a choice) but has the disadvantage that you can't go back once you've made a choice. Difficult for bad typists like myself.

make menuconfig is a textlike (although it is graphical) menu. You have the option to go back if you've made mistakes.

make oldconfig takes your old configuration (that will be gone if you did make mrproper) and uses it. I've found it handy in recompiling RedHat on an older machine (see my RedHat article listed above) or when just using patches. (see below.)

When done, regardless of the menu you've chosen, you're then asked if you want to save the new configuration. Assuming your ready to risk it, choose yes.


make dep; make clean; make bzImage

The bzImage part is what is going to take awhile. On an AMD 1 Gig processor with 256 megs of RAM it takes me about 10 minutes--on a low end, older machine (K6-II 450 with 192 megs of RAM) it takes about 30 minutes. Here is where you might get error messages if you've left out something important. Assuming you didn't, once that's done

make modules; make modules_install

(Actually, one only needs to type make once--you could simply type make dep clean bzImage modules modules_install---I like to pause after bzImage to make sure there are no errors)

Recently, there was some discussion on one of the mailing lists about the proper order here. A bit of research indicates that it's not that important whether one does make dep clean or make clean dep---doing a make clean will NOT clean out the dependencies that you just made. The latest (2.4.14) kernel README doesn't even mention make clean, and even the kernel howto mentions it as an option for older kernels--though, from the context, one isn't sure if they mean older as in from a long time ago, or older as in the kernel that you had before compiling the new one.

Others think that you should do make modules modules_install before doing make bzImage. I've never seen it dogmatically stated either way--the make modules modules_install option is listed after make bzImage in the 2.4.14 kernel README, the kernel howto and RH's kernel howto. I've always done it that way without problems--however, others have done make modules modules_install before making the bzImage. To be safe, just keep the groups together--that is make dep clean and make modules modules_install. The make dep clean (or clean dep if it makes you feel safer) should come first. Then, either make bzImage or, if you want to try it make modules modules_install. Then, lastly bzImage or the two modules commands, depending upon which one you did previously. I reiterate, I have heard that people do the make modules modules_install step first without problems, but I have never done it that way.

A RedHat default kernel is modular, and has a lot of default modules that are unneeded--in such a case, this part too can take awhile. If you've done a monolithic kernel (that is, with no modular support) you can skip this part--otherwise, you'll get an error message. However, if you have chosen to enable module support, even if you haven't used any modules, don't skip it.

Next, we copy the bzImage over to boot

cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.10

This is assuming that the new kernel is 2.4.10, obviously.

If you're using Grub, which is becoming more and more common (see my grub page then add the following entry to grub/menu.lst or grub/grub.conf (depending upon your distro.) Let's assume that your 2.4.9 kernel is on /dev/hda2 or (hd0, 1) in grub terminology. So, say grub already has the lines:

title Linux
root (hd0,1)
kernel /boot/vmlinuz-2.4.9 ro root=/dev/hda2

Add the lines

title Linux New
root (hd0,1)
kernel /boot/vmlinuz-2.4.10 ro root=/dev/hda2

In other words, you're adding a new title and a new boot image. The rest of it will be indentical to what you already have.

If you're running LILO then say you have the lines:


Then add:


Again, an almost duplicate entry, simply adding a new label and new boot image. Then, run lilo


You should see a message that it added linux and added linuxnew (Note that with lilo there can be no spaces in the label)

Now reboot, and see what happens. If it doesn't boot for some reason, see if the error messages give a clue, go back and once again run make menuconfig (or whichever you chose) and see if the error can be fixed. If it boots, and hangs at

Ok, uncompressing the kernel

that often means you chose the wrong processor during configuration. If it does work, you might want to keep the old configuration around for a few days to make sure there's nothing you've forgotten, then you can delete the vmlinuz-2.4.9 in your /boot partition and also get rid of the linux.bak drectory.

Lastly, patches. Rather than downloading an entire kernel, you can simpy download the patch. Move it to /usr/src

mv patch -2.4.10.bz2 /usr/src/

Directions for applying it are in the linux/README

cat linux/README | grep patch

They're quite smple--if you've downloaded a bz2 file then it's

bzip2 -dc patch-2.4.10.bz2 | patch -p0

If you downloaded a .gz file then it's

gzip -cd patch-2.4.10.gz | patch -p0

(This should be done from /usr/src) You can check that your kernel has been upgraded by checking the Makefile

head linux/Makefile

You should see

This indicates that your kernel has been successfully patched. However, if you reboot, you'll see that you're still running the 2.4.9 kernel. The next step is cd back to /usr/src/linux

make oldconfig; make dep; make clean; make bzImage

and from there, continue with the steps given above

make modules; make modules_install

cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.10

When you reboot, you should see that your kernel was successfully upgraded. Well, as said, this is a brief list of instructions. It should help to get you started.