I am trying to compile a custom kernel for Nvidia's Jetson TK1 board, and it seems that as well as the kernel itself (zImage) I will need /usr/src/linux-headers-{version} and /lib/modules/{version}.

However I can't see how to create the linux-headers. I have tried running make headers_install but it does not seem to create the same type of output as what I see in other /usr/src/linux-headers directories.

I've seen other similar questions such as here, however this assumes you are building the same version as you are running, where I am trying to build with a different LOCAL_VERSION.

I am starting from a "Linux4Tegra" distro, however, I am attempting to make a custom system based on Ubuntu Core.

To clarify, I am trying to create a kernel with my own LOCAL_VERSION, i.e., my own version, not an existing version in any repository. I would like to generate the headers that match this. So installing a linux-headers-xxx package will not address my problem.

My question is how are these packages initially created from the linux source?

When I look at the files in the existing headers directories, it contains references to that kernel version, so I am assuming that this has been generated from that version of the linux source. How can I generate these? When someone is compiling a version of the kernel, surely they generate these files somehow?

  • add your distro to the post please Commented Mar 16, 2016 at 6:30
  • Run sudo apt-get install linux-headers-generic Commented Mar 16, 2016 at 6:37
  • How does the output vary from what you'd normally see in /usr/src/linux-headers? Commented Mar 16, 2016 at 7:53
  • Not at my computer until tomorrow, but the output is basically completely different. No commonality whatsoever as far as I could see.
    – Alex
    Commented Mar 16, 2016 at 8:39

1 Answer 1


Late answer. I recently encountered this problem and I found a possible answer.

Suppose you want to install the kernel header file to /usr/src/linux-headers-4.15.3. The compiled kernel source tree is located /path/to/compiled/linux-4.15.3/

first, unpack a clean kernel source tree

tar xvf linux-4.15.3.tar.xz
cd linux-4.15.3/

second, copy you .config file to the directory

cp /path/to/compiled/linux-4.15.3/.config .

third, run it and then delete .config file in source directory to get a clean kernel source

make O=/usr/src/linux-headers-4.15.3 oldconfig
rm .config

fourth, run the modules_prepare make target

make O=/usr/src/linux-headers-4.15.3 modules_prepare

Finally, delete useless things, and copy the necessary things

rm /usr/src/linux-headers-4.15.3/source
cp /path/to/compiled/linux-4.15.3/Module.symvers /usr/src/linux-headers-4.15.3

Now, the /usr/src/linux-headers-4.15.3 directory is able to build the module.

Documentation https://www.kernel.org/doc/Documentation/kbuild/modules.txt tell us modules_prepare

This will make sure the kernel contains the information required. The target exists solely as a simple way to prepare a kernel source tree for building external modules.

NOTE: "modules_prepare" will not build Module.symvers even if CONFIG_MODVERSIONS is set; therefore, a full kernel build needs to be executed to make module versioning work.

  • This does not work for a strange reason: ~$ tar -xf linux-5.10.10.tar.xz ~$ cd linux-5.10.10/ ~/linux-5.10.10$ make mrproper ~/linux-5.10.10$ cp ~/config_sys .config ~/linux-5.10.10$ make O=/usr/src/linux-headers-5.10.10 oldconfig make[1]: Entering directory '/usr/src/linux-headers-5.10.10' *** *** The source tree is not clean, please run 'make mrproper' *** in /home/nuclear/linux-5.10.10 *** make[1]: *** [/home/nuclear/linux-5.10.10/Makefile:547: outputmakefile] Error 1 make[1]: Leaving directory '/usr/src/linux-headers-5.10.10' make: *** [Makefile:185: __sub-make] Error 2
    – Nuclear
    Commented Jan 19, 2022 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .