Kernel Compilation / Create new (patched) kernel for linux

Debian is used here for explanation but the same steps can be extended for other linux flavors also

Prerequisites

  • Debian GNU/Linux 8.2 amd64/i686 operating system
  • In the installation wizard, select software development while selecting packages.
  • Kernel Source (linux-source-3.16.tar.xz) available at /usr/src/ on Debian 8 machine

Building Kernel

#(Extract the Kernel Source under /usr/src directory)
cd /usr/src
tar -xf linux-source-3.16.tar.xz
cd /usr/src/linux-source-3.16
#If you need custom config options create one file named ".config" in  /usr/src/linux-source-3.16
#e.g. sample .config file 
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
# Apply your patches or do required changes in source code

# Kernel Compilation command for debian 
make deb-pkg LOCALVERSION=-ji-sample-kernel KDEB_PKGVERSION=0
Note:- Debian packages will be created under /usr/src directory
linux-headers-3.16.7-ji-sample-kernel_0_amd64.deb
linux-image-3.16.7-ji-sample-kernel_0_amd64.deb
linux-image-3.16.7-ji-sample-kernel-dbg_0_amd64.deb
linux-libc-dev_0_amd64.deb

Install these .deb files and restart your machine, in boot menu you will find newly installed kernel.

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s