5 Steps: Build a custom kernel in Debian Wheezy (…including NVIDIA drivers)

There may be many reasons to build your custom kernel. Either you have bought a new piece of hardware that is not supported by your current distribution, enable or disable features or just because you can.

Here are five easy steps to build a custom kernel on a debian system including NVIDIA kernel module. There may be way better tutorials on building a custom kernel out there, I just want to give you the essential steps that I use…

As I am writing this the latest kernel from the mainline is version 3.5. The latest stable release, which is what I recommend to build, is 3.4.6. But the following steps are for building the latest release from the mainline. 
So become root by typing “su” and entering your password in the console.
Make sure you have the requirements for building a kernel and the nvidia modules installed. If not you can install them by running:
$ apt-get install -f module-assistant build-essential

1. Download the full source code from kernel.org and extract it to /usr/src:

$ cd /usr/src/

$ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.5.tr.bz2
$ tar -jxf linux-3.5.tar.bz2

2. Take the configuration of your current kernel by running:

$ make oldconfig
The script asks you for settings of features that were not available in your current kernel and therefore not available in the current configuration. I recommend to select the default values (by simply pressing ENTER several times).

3. Edit the kernel configuration

make xconfig

This will bring up a GUI that makes it easy to edit the kernel configuration.

4. Build the kernel, install the modules and install the kernel

$ make
$ make modules_install
$ make install

Then reboot the system. Boot the new kernel you installed by selecting it from the GRUB boot menu. The system will not boot to graphical desktop unless you have configured X to use the nouveau driver. So the last step is installing the NVIDIA driver.

5. Install the NVIDIA driver

Log in as root and run the module assistant to compile and install the NVIDIA kernel module.

$ m-a auto-install nvidia-kernel
After the installation is finished reboot the system and you’re done 🙂


Update: How to patch the custom kernel 

Kernel 3.5.1 was released. There is no need to Download the full source. You can simply download the patch and apply it to your source. Become root by typing “su” and your password and change to /usr/src.
Download the patch:
$ wget http://www.kernel.org/pub/linux/kernel/v3.0/patch-3.5.1.bz2
Extract it: 
$ bunzip2 patch-3.5.1.bz2
Change to source dir and apply the patch:
$ cd linux-3.5
$ patch -p1 < ../patch-3.5.1
Configure, build and install the updated kernel:
$ make oldconfig
$ make
$ make modules_install
$ make install
You also need to repeat the last step from above to rebuild the NVIDIA driver:
$ m-a auto-install nvidia-kernel
Reboot and enjoy the latest version of Linux 🙂 

One Reply to “5 Steps: Build a custom kernel in Debian Wheezy (…including NVIDIA drivers)”

  1. Hello,

    Your tutorial is quite helpful!

    Just wanted to ask you — I have kernel 3.6 with Debian Wheezy, and a Sunplus integrated webcam on Lenovo laptop. The cam is not detected, although lsusb lists the device. Could you say what needs to be done?

    I recompiled the kernel with the Sunplus module enabled under GSPCA, but it still didn't work.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.