Building the kernel is usually what takes the longest amount of time. If you have an older machine with a slower processor it can take as long as a couple of hours. It is possible to build your kernel on a fast machine and then later copy it to the slower machine, but I won't be covering that here. I built kernel 2.2.19 on my high-speed-low-drag pentium 120 with 128MB of RAM and it took about 20-25 minutes. Not to shabby. (and yes, "high-speed-low-drag" is an industry term)
To build the kernel we will be using a program called make-kpkg. Before we start using it, we need to talk about revisions and flavours. I will only be covering these subjects lightly. It's a good idea to reference the documentation that was installed with this package.
make-kpkg is part of the "kernel-package" package. The relevant documents should be located in /usr/share/doc/kernel-package/. It's not a bad idea to also consult man make-kpkg. |
Revision is an option you will be passing to make-kpkg, which will add some extra information on to the end of the name of the debianized kernel. This is important because it will help keep stock kernels which may be available in the archive from "upgrading" your kernel. This is especially true if you use dselect or apt-get to upgrade your packages. The important thing to remember about the revision option is that you can only use alphanumeric characters and the "+" character. Do not use underscores "_". You may also prepend the revision with a digit followed by a colon ":".
We will be using the option --revision=custom.1.0 kernel_image for this tutorial. You could also prepend that with a colon ":".
If you decide to use the form --revision=1:custom.1.0 kernel_image Please read /usr/share/doc/kernel-package/README. This creates an epoch. The discussion of that is beyond the scope of this document (for now). |
Please read /usr/share/doc/kernel-package/README if any of the preceding paragraph was unclear or if you plan on using options that are different then the ones I suggest. |
The flavours option is a lot like revisions in that they create information which is added to the package name. They also follow the same naming rules: It may contain only alphanumerics and the characters "-" "+" "." Do not use uppercase letters or hyphens. The primary reason to use the flavour option is if you're compiling a kernel with the same version number as the one you are currently running.
You will need to do make-kpkg clean FIRST if you wish to recompile the kernel-image using a flavour. There are also module conflict issues you need to worry about. |
If you followed my advice and got a kernel version different than the one you are currently running, you won't have to worry about the flavours option. If you don't have a choice then please consult the flavours documentation. In future versions I hope to cover this in more detail. If you are knowledgable about this and would like to coauthor please contact me at <newbiedoc-discuss@lists.sourceforge.net>.
Please read /usr/share/doc/kernel-package/Flavours if you are compiling a custom kernel with the same version number as the one you are currently running. You can find out which version you are running on the bottom of this page. |
You can get by without using the flavours options if you're willing to get rid of your old modules and overwrite your current kernel. I don't recommend this because if you make a mistake, your only recourse is a boot floppy (if you made one!) and some repairs with utilities you probably aren't that familiar with. I try to avoid stuff like that as much as possible. If you're adventurous and want to give it a try, go for it. Just make sure your important data is backed up and you have a current boot floppy. |
Before we make the kernel the first thing we need to do is make a boot disk. This way, if anything gets screwed up we will still be able to boot the machine and (hopefully) fix it without having to reinstall. You can make a boot disk by grabbing a floppy disk which you don't mind erasing and doing this (as the root user):
bash# mkboot path_to_kernel |
Replace path_to_kernel with the appropriate information. This is usually something like /boot/vmlinuz-2.2.17. The directory /boot is where your current kernel is (unless you put it somewhere else). vmlinuz is the name of your kernel and its version will be appended to the end. (unless you have compiled a kernel before, in which case it may be bzImage or zImage.)
Finally! The time has arrived. We are now ready to make the kernel image and modules. Execute the command (as a regular user):
bash$ cd /usr/src/linux And then do: bash:/usr/src/linux$ make-kpkg --revision=custom.1.0 kernel_image |
Do not change the kernel_image target with your kernel version. That command should be executed exactly as above (unless you used a different revision number).
Now all you can do is wait for the computer to finish. Take a few minutes off and enjoy yourself while the computer does its fair share of the work.
If you've already used this document to install a kernel as a Debian package you'll need to make sure you increment your revision number by some amount. For example you would change the above revision number to 1.1 or maybe 2.0. You'll need to do this because dpkg will not upgrade your previous kernel because it sees the same revision number and thinks it's already current. You will also need to move you're old modules "out of the way" by renaming their folder to something like 2.2.19-old. The modules are located in /lib/modules/. |