Debian - Compile Your Own Kernel

Recently I was looking to compile my own kernel that has a few custom patches. Here is how I did it.

Determine your kernel version by running:

  1. uname -r
  2. 3.2.46

Install the following if they are not already:
sudo apt-get install bzip2 kernel-package linux-source-3.2 fakeroot build-essential ncurses-dev

Copy and unpackage the Kernel source:

  1. cd /usr/src/
  2. cp linux-source-3.2.tar.bz2 ~/
  3. cd ~/
  4. tar -jxf linux-source-3.2.tar.bz2

Now setup the config - Note that I wanted to use the vanilla config, but if you want your own config use the command: make menuconfig:

  1. cd linux-source-3.2/
  2. cat /boot/config-`uname -r`>.config

Then, cleanup files if you need to and start the build:

  1. make-kpkg clean
  2. fakeroot make-kpkg --initrd --revision=3myKernel.1.0 kernel_image kernel_headers

Now finally install your packages and reboot:

  1. sudo dpkg -i ../linux-image-3.2.46_3myKernel.1.0_amd64.deb
  2. sudo dpkg -i ../linux-headers-3.2.46_3myKernel.1.0_amd64.deb
  3. sudo reboot -f

Don't forget to select your new kernel.

Cleanup any kernel images your not using (I warn you here!)
sudo apt-get remove $(dpkg -l|egrep '^ii  linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`)

References:

http://linuxg.net/compile-kernel-3-9-on-debian-wheezy/
http://www.debian.org/releases/stable/i386/ch08s06.html.en
http://www.tux.org/~tbr/debiankernelpkg/

Blog tags: 

Comments

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.