TL;DR: Once I already compiled the Linux (Debian) kernel with "make deb-pkg", how to generate a new one after minor changes in .config?


I'm trying to compile the kernel following https://www.debian.org/doc//manuals/debian-handbook/sect.kernel-compilation.pl.html. Well, I did. It took a while, then I installed it, but it doesn't start.

So I'm trying again. I edited the .config and want to compile a new one. But I can't find a way to do it without starting all over, removing and then compiling the whole thing. Just "make" seems to do nothing. I mean, it does something, but doesn't change the linux-image. Just "make deb-pkg", without removing all the produced files before, returns error.

I searched for it, but all the answers I found seems to predate the use of "make deb-pkg" and didn't work.

Thank you.


1 Answer 1


In the beginning of Chapter 8.10.4 of the very handbook you linked:

NOTE Clean up before rebuilding

If you have already compiled once in the directory and wish to rebuild everything from scratch (for example, because you substantially changed the kernel configuration), you will have to run make clean to remove the compiled files.

At its heart, the make command uses a series of simple rules defined in Makefiles. For example, one rule might say that file X is built from files A, B and C using these commands. When deciding if file X needs to be rebuilt or not, make will usually just check if X exists, and if it does, whether it is newer than any of the source files A, B or C. If X does not exist or is older than one of its sources, it will be rebuilt.

If there are other rules for building A, B and/or C, they will be evaluated first before deciding on X, and so on, recursively.

(Over the decades of its existence, the make command and especially its GNU version have accumulated many extensions, but this is still the basic idea behind its operations.)

You said you made "minor changes in .config". Some of the .config options enable/disable new modules to be built. If you e.g. enable a module that used to be disabled, that would require a new *.ko file to exist that was not there before, and that would most likely be detectable by the kernel Makefile system.

But other options only cause changes by activating/deactivating some #ifdef blocks within individual source code files, or by changing some #define values. These can not be easily detected by the kernel Makefile system.

So, without knowing exactly what your kernel configuration was before and the exact option(s) you changed, it will be impossible to say whether this is a known/expected issue or something that should have worked.

The kernel Makefile system is a pretty complicated thing by itself; it's probably far too complicated to cover all the possible combinations of changes to kernel configuration options in a mathematically perfect fashion - it will err on the side of caution, ensuring that all configuration changes take effect. Sometimes that can cause rebuilding of more files than would be strictly optimal. A configuration change will update include/generated/autoconf.h, which is included by include/linux/kconfig.h, and since the latter is included by default, this would cause basically everything to be rebuilt anyway.

Based on the NOTE I quoted above, the recommended procedure seems to be: "before re-running make deb-pkg, run make clean".

I have experienced something similar with make deb-pkg: if I recall correctly, I think the error in re-running it is related more to the .deb package building steps than to the actual kernel compilation.

  • Yeah, I had read that note. Shoud have mentioned it. The make clean seems to make no difference. The error is the same. In fact, the execution of make deb-pkg shows make clean is one of its steps already. I can only recompile using rm in all files and starting again. Commented Jan 24, 2022 at 17:52
  • All the error messages, for various files, are are of the form: cannot represent change to debian/linux-headers/usr/src/linux-headers-5.10.84/scripts/sorttable: binary file contents changed warning: executable mode 0755 of 'debian/linux-headers/usr/src/linux-headers-5.10.84/scripts/sorttable' will not be represented in diff And then dpkg-source: error: unrepresentable changes to source Commented Jan 24, 2022 at 17:56

You must log in to answer this question.

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