Home of Rob
Menu
Kernel Compiling
Introduction
Compiling a Linux kernel is much easier than it might at first sound. Having said that, it goes without saying that anything you do to your own kernel and computer is done entirely at your own risk and I take no responsibility for things going completely and utterly pear-shaped, leaving you with a box filled with silicon chips and wires, standing where your beautiful Linux PC used to be.
The Tools
To build a Linux kernel you need various build tools, many of which come with the Linux distribution so you won't need to download them.
| Software Package | Minimum Version | Command to Show Version |
|---|---|---|
| binutils | 2.12 | ld -v |
| gcc (GNU C Compiler) | 2.95.3 | gcc --version |
| make (GNU make) | 3.78 | make --version |
| module-init-tools | 0.9.10 | depmod -V |
The Source Code
To build a linux kernel you need to download the source code from here. Download the version you're after and unzip the content to a folder on your PC. I tend to use /usr/src/
(adjust for whichever version you're using). To configure the kernel use make menuconfig but note that this requires you to have ncurses installed so if there are error messages displayed check that you have this tool. The configuration is stored in a file called .config which can be edited manually if you want.
Once you've configured the kernel you can build it with make The binary output file is found in /arch/
Documentation
Linus kernel documentation is found in /documentation within the kernel tarballs. If you want more information about how the kernel build system works, or other kernel related topics, this is a good place to start (though not all the documentation is rigorously maintained).
I have recently found an excellent piece of documentation for those new to Linux Kernel development. Here [Linux Kernel in a Nutshell] you'll find a book by Greg Kroah-Hartman which he's kindly made available as a free download. It starts with the basics and explains clearly how to compile your own kernel. I recommend reading it!