Differences between revisions 23 and 110 (spanning 87 versions)
Revision 23 as of 2008-04-09 06:04:47
Size: 5241
Editor: madduck
Revision 110 as of 2018-09-25 20:49:30
Size: 482
Editor: BenHutchings
Comment: Update kernel-handbook URL
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Building custom kernel packages = #language en
||<tablestyle="width: 100%;" style="border: 0px hidden">~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English - [[it/HowToRebuildAnOfficialDebianKernelPackage|Italiano]]-~||<style="text-align: right;border: 0px hidden"> (!) [[/Discussion|Discussion]]||
Line 3: Line 4:
(this wiki page should be renamed/moved to better reflect the actual content) See the Kernel Handbook section [[https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official|Rebuilding official Debian kernel packages]].
Line 5: Line 6:
This page is about rebuilding an official Debian kernel package with custom
changes. There is the Kernel Handbook about this:

We are following section 4.2: '''Rebuilding an official Debian kernel package'''

 * Reasons to do this:
  1.#1 Modifying the Debian configuration to change the '''preemption model'''.
  1.#2 Modifying the Debian configuration to change the '''timer frequency'''.
  1.#3 Modifying the Debian configuration to change to '''Pata'''.
  1.#4 Add an patch fix.
  1.#5 Add your favorite patchset.
What you'll get is exactly the kernel that Debian releases but with those
added changes. The new packages will not step on the official kernel images'

== Add a patch to linux-2.6 and build new kernel packages ==

  1. Create the directory where you will build the kernel package as a normal
  user and make sure you have all necessary packages installed:
  apt-get install fakeroot build-essential
  apt-get build-dep linux-2.6

  1.#2 Get the package source. For this to work, you need to have
  {{{deb-src}}} lines for the official archive in {{{/etc/apt/sources.list}}}:
  apt-get source linux-2.6
  cd linux-2.6-*

  Now you are in the tree that holds the source and all changes Debian made to it.

  As an alternative, you could get a kernel tarball, e.g. from buildserver
  (see DebianKernel), unpack it, and get the latest Debian patches + config
  tar xzf linux-2.6_2.6.24~rc6.orig.tar.gz
  cd linux-2.6-*
  svn export svn://svn.debian.org/svn/kernel/dists/trunk/linux-2.6/debian

  1.#3 Start a new stanza at the top of {{{debian/changelog}}} and use an
  appropriate version number. If you are adding a single patch "foo", you
  might want to append "+foo.1". If you are adding multiple patches for your
  company or yourself, use "+somename.1". You could do this with the {{{dch}}}
  tool from the {{{devscripts}}} package like so:
  dch --local +foo.

  1.#4 Append the same string to the {{{abi.abiname}}} field in
  {{{debian/config/defines}}} to ensure that your custom kernel package name
  doesn't bite with the official ones. In our case, we're now creating

  1.#5 Put your patch into the {{{debian/patches}}} directory and add it to
  the series file (assuming {{{debian/patches/series/1}}} is the latest file
  in there):
  cp ~/special-fix.patch debian/patches/bugfix/
  echo "+ bugfix/special-fix.patch" >> debian/patches/series/1+foo.1

  Now check that your patchset still applies and fix any conflicts
  make -f debian/rules source-all

  1.#6 Document the addition of this patch in the new stanza in {{{debian/changelog}}}.

=== Building all kernel-related packages ===

  7.#7 Assuming you want to build '''all''' kernel-related packages, build
  with the appropriate {{{DEBIAN_KERNEL_JOBS}}} parameter (the number of
  processors you can use for the build):
  ~/src/linux-2.6-2.6.24~rc6$ DEBIAN_KERNEL_JOBS=${NR_CPUS} debuild

=== Building only a single kernel variant ===

  7.#7 Prepare the rules file for the one build you want to make:
  fakeroot make -f debian/rules.gen setup_i386_none_k7

  This presumes you are only interested in building a k7 AMD processor image!
  If you where interested in a 686 processor image do:
  fakeroot make -f debian/rules.gen setup_i386_none_686

  This will build a tree in the {{{debian/build/build-i386-none-k7}}} or
  {{{debian/build/build-i386-none-686}}} directory.

  Go to that directory.

  1.#8 Change the {{{.config}}} file, using e.g.
  make menuconfig

  1.#9 Compile the kernel and generate the kernel packages. Replace
  {{{$NR_CPUS}}} with the number of CPUs of the build machine (keeping it
  all on the same line) and run either
  fakeroot make -f debian/rules.gen binary-arch_i386_none_k7 binary-indep \

  fakeroot make -f debian/rules.gen binary-arch_i386_none_686 binary-indep \

  On a 2.0GHz CPU the compile will take 1 hour and 20 minutes and 8 package files
  will be generated, e.g.:

  '''Problem''': In this case, {{{linux-headers-2.6.24-1+foo.1-common}}} will
  be missing. One needs to invoke the {{{binary-arch_i386}}} target, which
  will yield all feature sets (Xen, VServer) and flavours to be generated, and
  obviously takes a lot longer. See
  [http://lists.debian.org/debian-kernel/2008/04/msg00190.html this thread].
 . CategoryKernel

Translation(s): English - Italiano

(!) ?Discussion

See the Kernel Handbook section Rebuilding official Debian kernel packages.