How to Get, Examine, and Compile the Raspbian Linux Kernel Source Code

One of the great features of the Raspberry Pi is that the source code for the operating system (with the exception of some firmware code) is open for all to see and alter. I consider it a rite of passage for Linux folks to do this although in recent years it has become rather rare that it is necessary - just using the prepackaged kernels seems to work very well.

The truly wonderful aspect of having the source code is that the curious mind can learn in detail how a modern operating system works. The Linux code, written in C with some assembly code, is the result of decades of refinement by thousands of outstanding programmers. The kernel source code is also the ultimate documentation of how your programs must interact with the linux operating system.

A summary of how to download and compile the Raspbian kernel code is at The clone step brings in a 1.4 GB directory tree under the name linux. The compilation process on a Raspberry Pi 3 takes about 90 minutes using all 4 cores. During that time my Pi core temperature increased from about 50 Celsius to nearly 90 Celsius, close to the maximum tolerable. That Pi did not have the heat sinks supplied by CanaKit which makes me feel that those heat sinks are probably a good idea.

The exact mix of features compiled into the kernel is controlled by a file called .config which has thousands of lines specifying which features are to be left out, built into the kernel, or made into modules to be loaded as needed. More information is at

There, it is suggested to "Resist the temptation to enable or disable a lot of things on your first attempt...". This is important advice. In fact, it is a good idea to first try a practice run without making any changes at all to the original linux/.config. Many of the options may take some research to understand. Usually, somewhere you will find advice that in order to get some unusual device to work you must recompile a kernel with options XXX and YYY selected either as built in or as a modules.

In order to see what version of Linux you are currently using do:

	uname -a

And in order to see what .config was used for that kernel, do:

	sudo modprobe configs
	vi /proc/config.gz

Last updated: July 12, 2016

Valid CSS! Valid XHTML 1.0 Strict

Support Wikipedia

Contact Craig Van Degrift if you have problems or questions with this web site.