Difference between revisions of "Linux: Kernel development for x86 modules"

From Compulab Mediawiki
Jump to: navigation, search
(No difference)

Latest revision as of 14:48, 31 August 2015


The purpose of this page is to give the user a minimum amount of information to meet the goal of making a simple change to the kernel, building and installing it.

Obtaining the kernel sources

Original sources, changelog and deb files for desired kernel version can be found in Ubuntu Packages archive.

For example sources of kernel 3.16.0-38-generic compiled for Ubuntu 14.04 (Trusty Tahr) are placed here linux-image-3.16.0-38-generic

  • linux_x.y.z.orig.tar.gz - mainline Linux x.y.z sources
  • linux_x.y.z-xx.yy.diff - Ubuntu patch
  • config-x.y.z-xx-generic - Ubuntu configuration file (can be found inside linux-image-x.y.z-xx-generic_xxx_amd64.deb)

If modifications provided by Compulab - use CompuLab's patch in addition to Ubuntu patch, use CompuLab's config file instead of Ubuntu's one

  • compulab.x.y.z-module_name.diff - CompuLab patch for the module
  • config-x.y.z-xx-compulab.module_name - CompuLab config file


  • Use a 64-bit machine with Ubuntu, LinuxMint, or another compatible distribution as kernel building host workstation
  • Install the programs and tools required for kernel building
$ sudo apt-get install libncurses5 libncurses5-dev kernel-package build-essential
  • Prepare sources, apply patches and prepare initial config file
$ cd /path/to/module_name/kernel
$ tar -xvzf linux_x.y.z.orig.tar.gz
$ cd linux-x.y.z
$ patch -p1 < ../patches/linux_x.y.z-xx.yy.diff
$ patch -p1 < ../patches/compulab.x.y.z-module_name.diff
$ cp ../config-x.y.z-xx-compulab.module_name .config
  • Make modifications for your needs and configure the new kernel
    • (optional) change CONFIG_LOCALVERSION="-compulab.module_name" to "-yourname.module_name"
$ make menuconfig
  • If you have a more than one processor or more than one core, you can speed things up by running concurrent compile commands. Setup CONCURRENCY_LEVEL=16 for 8 cores
  • Compile the kernel and create the .deb packages
    • (optional) revision=yyyy.mm.dd can be changed to another custom string, it will appear as part of the .deb file name
$ fakeroot make-kpkg --initrd --revision=yyyy.mm.dd kernel_image kernel_headers
  • The linux-image-*.deb and linux-headers-*.deb packages will be created in the parent directory


  • Make the linux-*.deb files accessible from the module, for example mount them with NFS or attach a disk-on-key with the files
  • Install new linux-*.deb packages:
sudo dpkg -i /path/to/linux-*.deb