Compiling the kernel with additional patches


Recommended Posts

(I know there's already a thread on this subject, but this one is also about extra kernel patches. Mods, do with it as you wish :p )

Compiling the kernel and adding patches

---------------------------------------

There are many possible reasons for wanting to compile a kernel with additional patches. One can try new features, hope for a speed increase, require a security fix... In my case, I wanted to try the latest bcm43xx driver (I would like to run some tests and give feedback to the developers, and on top of that, the new driver is said to work better with my wireless card).

On request of h3xis, and keeping in mind that others might want to add patches before compiling their kernel, I've written this guide. I've recompiled my kernel on Ubuntu 6.10, so instructions for other distributions might be slightly different!

IMPORTANT NOTICE!! Compiling your kernel could cause damage to your system, especially if you use conflicting packages! So be very careful, and don't forget to make a back-up!

I've based this guide on this page, with a few differences.

If a command does not work, try it again with 'sudo' added at the beginning!

Note: if anything goes wrong, it's your own responsibility!

1. Installing the required packages for compiling the kernel:

sudo apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev wget libncurses5 libncurses5-dev && cd /usr/src

2. Downloading and unpacking the kernel:

First, go to http://kernel.org/pub/linux/kernel/v2.6/, and choose the kernel you wish to compile (normally, you'll need the most recent one). Download it and unpack it in /usr/src. You will then have a folder /usr/src/linux-VERSION.

3. Changing links:

Make sure you're in /usr/src right now.

We're going to remove the current symbolic link at /usr/src/linux, and replace it by a link to our new kernel (soon to be compiled). Then, we'll move into the /usr/src/linux directory.

It's possible you don't have a /usr/src/linux directory. In that case, you don't need to remove the symbolic link (however, you still need to do the rest of the step).

We'll do this by using the following code.

sudo rm -rf linux && sudo ln -s /usr/src/linux-VERSION linux && cd /usr/src/linux

4.A. Adding official kernel patches

It's possible that you already have the source of kernel 'VERSION.smallversion' on your computer, but would like to use kernel 'VERSION.smallversion+X' instead. You could download the entire source to kernel 'VERSION.smallversion+X' (over 50 MB), or you could download 'patch-VERSION.smallversion+1', 'patch-VERSION.smallversion+2' and so on (could be a few kB up to a few MB).

Suppose you already have the source of an earlier kernel. You could download a kernel patch 'patch-VERSION.smallversion', decompress it in /usr/src/linux, and type the following code to add it to the kernel source:

patch -p1 < patch-VERSION.smallversion-DECOMPRESSED

By doing this, you will have patched your kernel!

4.B. Adding other kernel patches

If you have a kernel patch you wish to add, you simply decompress the patch into the /usr/src/linux folder, and type the following code:

patch -p1 < patch-DECOMPRESSED

5. Importing your previous kernel configuration and configuring the kernel

In this step, you'll use the previous kernel configuration, followed by answering lots of questions (if you're unsure about these, it's easiest to just keep pressing enter -- but if you need to set additional options: don't! I pressed enter, and I'll have to compile again to enable a debug-option on my bcm43xx-driver.).

sudo cp /boot/config-`uname -r` .config && sudo make oldconfig && sudo make xconfig

6. Compiling the kernel

Debian (and distributions based on it) has a configuration utility, called make-kpkg. It replaces a combination of commands and makes compiling the kernel easier.

[TO-DO: add explanation for non-Debian-based systems]

make-kpkg clean

Then, we'll do the actual compiling. Grab yourself a book, type the following code, and wait a few hours...

make-kpkg -initrd --revision=386 kernel_image kernel_headers modules_image

7. Finishing the job

Last, but not least, we need to install the created kernel packages.

There should be 2 .deb-packages in your /usr/src (one is a kernel image, the other a kernel header), so type:

cd /usr/src

Then, to install them:

dpkg -i KERNELIMAGE.deb && dpkg -i KERNELHEADER.deb

8. You made it!?

Now simply reboot, and that's it!

(If you have any comments, improvements, or have noticed errors, please do mention!)

  • 3 months later...
  • 2 weeks later...
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I agree when are you going to read this (really poor BTW) article? Here is a better article so you actually know what is going on and answers questions you had in other comments --> https://arstechnica.com/gadgets/2026/05/speed-boosting-low-latency-profile-is-one-of-the-improvements-coming-to-windows-11/ It is unclear if one will be able to disable the new profile at this point but I am not seeing any reason why one would.
    • I disagree; they come off very "bitchy" and "whiny". Make a great product and combine that with a great price (free) and people will come over to your side. Or build it and they will come as they say. Constantly trying to get attention by complaining all the time, will turn people off to your product.
    • It use to be a nightmare, with LibreOffice supporting a newer draft ODF standard by default, and Microsoft Office supporting the older non-draft standard. Now that they both support the same version of ODF, they should be interoperable.
    • Brave Browser 1.91.171 by Razvan Serea Brave Browser is a lightning-fast, secure web browser that stands out from the competition with its focus on privacy, security, and speed. With features like HTTPS Everywhere and built-in tracker blocking, Brave keeps your online activities safe from prying eyes. Brave is one of the safest browsers on the market today. It blocks third-party data storage. It protects from browser fingerprinting. And it does all this by default. Speed - Brave is built on Chromium, the same technology that powers Google Chrome, and is optimized for speed, providing a fast and responsive browsing experience. Brave Browser also features Brave Rewards, a system that rewards users with Basic Attention Tokens (BAT) for viewing opt-in ads. This innovative system provides an alternative revenue model for content creators and a way to support the Brave community. SlimBrave Neo takes all the good things about Brave and makes them even better by keeping everything clean, light, and privacy-focused. It removes the extra clutter, turns off features you might not need, and cuts down on anything that could slow you down or collect unnecessary data. Because it relies on simple settings and policies instead of modifying the browser itself, you still get full Brave compatibility—just in a smoother, lighter, and more privacy-friendly package. Brave Browser 1.91.171 changelog: General Fixed Cardano not being disabled on upgrade to Brave Origin. Upgraded Chromium to 149.0.7827.103. Origin Removed “Survey Panelist” setting from brave://settings/privacy. Fixed P3A and usage ping under brave://settings/privacy being displayed on first launch on Linux. Upgraded Chromium to 149.0.7827.103. Download: Brave Browser 64-bit | 1.2 MB (Freeware) Download: Brave Browser 32-bit View: Brave Homepage | Offline Installers | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Hi. As the title suggests, I can't access the forum on my phone. I'm using Edge on Android and when I try to navigate to the forum I get a "we value your privacy" popup and none of the buttons are clickable. It effectively stonewalls me from reading any forum content.
  • Recent Achievements

    • One Month Later
      Jamswaz earned a badge
      One Month Later
    • Week One Done
      Jamswaz earned a badge
      Week One Done
    • Rookie
      Marzoid went up a rank
      Rookie
    • Community Regular
      coch went up a rank
      Community Regular
    • One Year In
      slackerzz earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      519
    2. 2
      PsYcHoKiLLa
      190
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      75
  • Tell a friend

    Love Neowin? Tell a friend!