Build and install a custom kernel on Debian GNU/Linux

This post is reminder on how I got to build and install a custom kernel on Debian to be run on an Apple Macbook retina late 2013.

Fire up a browser to visit, download the "Latest Stable Kernel" by clicking on the big yellow button on the right. Then open a terminal and run

$> mv ~/Downloads/linux-4.2.tar.xz ~/src
$> cd ~/src
$> tar xf linux-4.2.tar.xz

to move kernel sources into the src folder and uncompress them. If you need, like me, to build broadcom-sta driver using dkms you need to fix a kernel regression in kernel\_workqueue.c replacing

--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2619,7 +2619,7 @@ void flush_workqueue(struct workqueue_struct *wq)

If you don't want to build the debug deb package you need to disable CONFIG\_DEBUG\_INFO by changing the kernel configuration launching make menuconfig Then to build it and get a deb package it's just two commands away:

$> make olddefconfig
$> make deb-pkg

After the kernel build finishes you should find some deb packages in the parent folder:

-rw-r--r--  1 fabio fabio 940K Sep 19 11:43 linux-firmware-image-4.2.0_4.2.0-1_amd64.deb
-rw-r--r--  1 fabio fabio 6.8M Sep 19 11:44 linux-headers-4.2.0_4.2.0-1_amd64.deb
-rw-r--r--  1 fabio fabio  32M Sep 19 11:45 linux-image-4.2.0_4.2.0-1_amd64.deb
-rw-r--r--  1 fabio fabio 314M Sep 19 12:05 linux-image-4.2.0-dbg_4.2.0-1_amd64.deb
-rw-r--r--  1 fabio fabio 787K Sep 19 11:44 linux-libc-dev_4.2.0-1_amd64.deb

I installed linux-headers and linux-image and rebooted into the new kernel.

Now you need to rebuild the dkms modules (like broadcom and virtualbox) by launching the following command as root:

#> dkms autoinstall -k 4.2.0

And it should be OK. I got problems in virtualbox on this kernel combination so it's still not perfectly OK but I hope I can fix it.

Last posts

  1. My mutt setup

    tags: mutt setup

  2. Back to i3

    tags: i3 tiling setup

  3. Primo post

    tags: pelican

  4. Get notified on network interface changes using libnetlink

    tags: netlinknetworking