How to speed up Linux kernel compilation?

momersaleem picture momersaleem · Apr 24, 2014 · Viewed 36.5k times · Source

I have core i5 with 8gb RAM. I have VMware workstation 10.0.1 installed on my machine. I have fedora 20 Desktop Edition installed on VMware as guest OS.

I am working on Linux kernel source code v 3.14.1. I am developing an I/O scheduler for Linux kernel. After any modifications in code every time it takes around 1 hour and 30 minutes for compiling and installing the whole kernel code to see the changes.

Compilation and Installation commands: make menuconfig, make, make modules, make modules_install, make install

So my question is it possible to reduce 1 hour and 30 minutes time into only 10 to 15 minutes?

Answer

rodrigo picture rodrigo · Apr 24, 2014

Do not do make menuconfig for every change you make to the sources, because it will trigger a full compilation of everything, no matter how trivial your change is. This is only needed when the configuration option of the kernel changes, and that should sheldom happen during your development.

Just do:

make

or if you prefer the parallel compilation:

make -j4

or whatever number of concurrent tasks you fancy.

Then the make install, etc. may be needed for deploying the recently built binaries, of course.

Another trick is to configure the kernel to the minimum needed for your tests. I've found that for many tasks a UML compilation (User Mode Linux) is the fastest. You may also find useful make localmodconfig instead of make menuconfig to start with.