Compiling device drivers with Ubuntu 10.04LTS

Asked by Michel Halde


I'm writing a custom device driver, and i would like to know how to build my modularized driver into Ubuntu 10.04LTS Kernel (2.6.32-27).

I've already installed the following directories: /usr/src/linux-headers-2.6.32-27, and /usr/src/linux-headers-2.6.32-27-generic. But no header .h files are there, just Kbuild, Makefile, Kconfig, etc.

Do we have build something to get .h files and objects from the Ubuntu's Kernel ? I need those files (.h and .o) for building my .ko file.

Thanks for your help.

Question information

English Edit question
Ubuntu linux-meta Edit question
No assignee Edit question
Solved by:
Eliah Kagan
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :

Did you install the build-essential package, that usually gives what is needed.

Revision history for this message
Michel Halde (softmike64) said :

I added the build-essential package, but i had no new .h files.

According to this documentation (, at the section "Reasons for NOT compiling a custom kernel", the first bullet describes exactly my case.

But i don't know which "linux-headers packages" to install...

The packages are already there into a stock ubuntu 10.04LTS desktop ? I have to "make" something under the /usr/src directories ?

Revision history for this message
Best Eliah Kagan (degeneracypressure) said :

You do need to install one of the linux-headers packages, if you don't already have that installed. You should install the one that corresponds to the linux package you have installed.

Open a Terminal window (Applications > Accessories > Terminal), type in the command "uname -r" (without the quotes), and press enter to run it. You should see something like:


The part after the numbers indicates which kernel "flavor" you have installed, and that's the linux-headers "flavor" you should install as well. For example, if yours says "generic" like mine does, then you should install linux-headers-generic. If you want to do this from the command-line (i.e. within the Terminal), you can do so with the command:

sudo apt-get install linux-headers-generic

If you installed the package whose name is linux-headers-(version), where (version) is your kernel version, then that's just a virtual package that tells Ubuntu that you have chosen to install and maintain the linux kernel headers manually. You probably don't want that.

Revision history for this message
Michel Halde (softmike64) said :

Thanks Eliah Kagan, that solved my question.