So I am patching my kernel to fix my Bluetooth and building using this guide https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

Why do I have to compile the entire kernel which takes about an hour?

  • If you are going to compile your own kernel, you may as well remove all the stuff you {d,w}on't need: compilation time should then be closer to ~15/20 minutes on a modern machine... – jasonwryan Jan 9 '15 at 2:48
  • @jasonwryan Whilest I agree with that in principle, if the OP doesn't know what his computer has and is using Ubuntu, where everything is "on" by default, he's better to wait the hour... – eyoung100 Jan 9 '15 at 3:20
  • @eyoung100 my comment was not in relation to the OP's competence, more to the possibility of kernel compilation taking significantly less than one hour... – jasonwryan Jan 9 '15 at 3:36

I'll assume your question is asking about the nature of the kernel, and why it would need recompiled.

The Linux kernel is a whole bunch of source code written in C. There is code available to handle an unbelievably huge number of computer hardware devices and chip sets, and more code that helps it adapt to different platforms other than the standard PC hardware. Then, there is the code that provides the overall structure of the thing at runtime.

Some of the code is mutually exclusive with other parts of the code, and you must choose one option or the other.

Some of the code is for special circumstances, which slows down the speed of the kernel for people who don't have those circumstances, and so you can set options that disable those bits of code.

When Ubuntu builds a kernel for "the masses", they take a guess at what hardware 99% of people will encounter and need. Then they divide as much as they can into loadable modules. Then they compile the main core of the kernel and ship that with most of the modules you'd need. They make other modules available with the package manager.

You didn't describe what was broken with your Bluetooth, but if someone said you need to build a new kernel, it probably means that one of those kernel options eliminated your ability to use a certain bluetooth chip. So, then you have to build a kernel which has that option enabled.

If you were lucky, you'd only need to build a bluetooth module with that new option. However, it can be very hard to get set up with the right compiler environment so that you end up with a new kernel module that correctly links into the existing kernel. In many cases its easier or more reliable to just recompile the whole thing.

Now, once you've done the first compile, small changes to the config will only need to recompile the few files that were affected, and it will be much faster. However, I suspect that fakeroot debian/rules clean is throwing away the temporary files and making you start from scratch. I would suggest skipping that step the second time. Also, check if it is using all your processors when compiling. If not, look around for some way to tell it to compile in parallel. When compiling by hand, I use make -j 20 which gives the fastest performance on a 4-core machine by compiling 20 files at a time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.