GitKernelBuild

Differences between revisions 10 and 55 (spanning 45 versions)
Revision 10 as of 2008-01-18 20:56:11
Size: 5699
Editor: c-67-160-148-53
Comment: add table of contents
Revision 55 as of 2025-01-31 23:23:40
Size: 6324
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;">'''Contents'''[[BR]][[TableOfContents]]|| ||<tablestyle="float:right; font-size: 0.9em; width:40%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;"><<TableOfContents>>||
Line 3: Line 3:
Many times patches for bugs are committed upstream but have yet to make their way down to the Ubuntu kernel.  It is often helpful if users are able to verify if the upstream patches do indeed resolve the issue they are witnessing.  Likewise, in the opposite situation, it is useful to know if a bug may still exist upstream. Many times patches for bugs are committed upstream but have yet to make their way down to the Ubuntu kernel. It is often helpful if users are able to verify if the upstream patches do indeed resolve the issue they are witnessing. Likewise, in the opposite situation, it is useful to know if a bug may still exist upstream.
Line 5: Line 5:
The following document should help users build their own kernel from the upstream mainline kernel to help verify if a bug still exists or not. If a bug is still present in the upstream kernel, it is encouraged that the bug be reported to http://bugzilla.kernel.org . The bug submission process for http://bugzilla.kernel.org is outlined at the end of the document. Please note that the following steps are targeted towards Ubuntu users and focuses on building the mainline kernel from the git repository at http://git.kernel.org . The following document should help users build their own kernel from the upstream mainline kernel to help verify if a bug still exists or not. If a bug is still present in the upstream kernel, it is encouraged that the bug be reported upstream following the procedure noted in [[KernelTeam/KernelTeamBugPolicies#Overview_on_Reporting_Bugs_Upstream|this page]]. Please note that the following steps are targeted towards Ubuntu users and focuses on building the mainline kernel from the git repository at http://git.kernel.org.

For building Ubuntu kernels please refer to [[https://help.ubuntu.com/community/Kernel/Compile]].
Line 9: Line 11:
There are a few tools that are necessary in order to build your own kernel(s).  The 'git-core' package provides the git revision control system which will be used to clone the mainline git repository.  The 'kernel-package' provides the make-kpkg utility which automatically build your kernel and generate the linux-image and linux-header .deb files which can be installed. You will need to install both of these packages.

{{{
sudo apt-get install git-core kernel-package fakeroot
There are a few tools that are necessary in order to build your own kernel(s). The 'git' (or 'git-core' for 10.04 or before) package provides the git revision control system which will be used to clone the mainline git repository. The 'kernel-package' provides the make-kpkg utility which automatically build your kernel and generate the linux-image and linux-header .deb files which can be installed. You will need to install the following packages: {{{
sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves
Line 16: Line 16:
 1. Change to the directory where you want to clone the git tree.  In this example we will use /usr/src
 
{{{ cd /usr/src

1. Change to the directory where you want to clone the git tree. In this example we will use $HOME: {{{
cd $HOME
Line 19: Line 20:
 1. Clone the mainline kernel git tree.
 
{{{ sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 1. Clone the mainline kernel git tree: {{{
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Line 22: Line 23:
 1. Change to linux-2.6 directory.
  {{{ cd linux-2.6
 1. Change to directory linux: {{{
cd linux
}}} (!) If you only want to test all commits up to and including a specific one, instead of every commit you just downloaded, one may execute: {{{
git checkout COMMIT
}}} where COMMIT is the specific commit number (ex. 9587190107d0c0cbaccbf7bf6b0245d29095a9ae).
 1. Copy the kernel config file from your existing system to the kernel tree: {{{
cp /boot/config-$(uname -r) .config
Line 25: Line 31:
 1. Copy the kernel config file from your existing system to the kernel tree.
  {{{ sudo cp /boot/config-`uname -r` .config
}}}
 1. Bring the config file up to date. (Answer any questions that get prompted).
  {{{ sudo make oldconfig
 1. Bring the config file up to date. Answer any questions that get prompted. Unless you know you are interested in a particular feature, accepting the default option by pressing Enter should be a safe choice: {{{
make oldconfig
Line 31: Line 34:
 1. (optional) If you need to make any kernel config changes, do the following and save your changes when prompted:
  {{{ sudo make menuconfig
 In cases where your kernel source is significantly newer than the existing config file, you'll be presented with all of the new config options for which there is no existing config file setting. You can either sit there and keep hitting Enter to take the default (generally safe), or you can just run: {{{
make olddefconfig
}}} which will set all the new options to the default values without listing them all for your inspection.
 1. (optional) If you need to make any kernel config changes, do the following and save your changes when prompted: {{{
make menuconfig
Line 34: Line 40:
 1. Clean the kernel source directory.
 
{{{ sudo make-kpkg clean
 1. Clean the kernel source directory: {{{
make clean
Line 37: Line 43:
 1. Build the linux-image and linux-header .deb files.
  {{{ sudo fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
 1. Build the linux-image and linux-header .deb files using a thread per core + 1. This process takes a lot of time: {{{
make -j $(getconf _NPROCESSORS_ONLN) deb-pkg LOCALVERSION=-custom
}}} With this command the package names will be something like linux-image-2.6.24-rc5-custom and linux-headers-2.6.24-rc5-custom, and in that case the version will be 2.6.24-rc5-custom-10.00.Custom. You may change the string "custom" into something else by changing the `LOCALVERSION` option.
 1. Change to one directory level up (this is where the linux-image and linux-header .deb files were put): {{{
cd ..
Line 40: Line 49:
 1. Change to one directory level up (this is where the linux-image and linux-header .deb files were put)
  
{{{ cd ..
}}}
 1. Now install the .deb files.  In this example, the files are linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb and linux-headers-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb.  You may receive warnings about '/lib/firmware/2.6.24-rc5-custom/' - this is expected and will only be problematic if the driver you are trying to test requires firmware.
 
{{{ sudo dpkg -i linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb

An alternative to build onl
y binary packages is:

{{{make -s -j$(getconf _NPROCESSORS_ONLN) olddefconfig bindeb-pkg LOCALVERSION=-custom }}}

which builds only binary packages, and uses a shortcut to use default settings for settings not included in .config.


1. Now install the .deb files. In this example, the files are linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb and linux-headers-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb. You may receive warnings about '/lib/firmware/2.6.24-rc5-custom/' - this is expected and will only be problematic if the driver you are trying to test requires firmware: {{{
sudo dpkg -i linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb
Line 47: Line 61:
 1. You are now ready to boot into your new kernel.  Just make sure you select the new kernel when you boot.
 
{{{ sudo reboot
 1. You are now ready to boot into your new kernel. Just make sure you select the new kernel when you boot: {{{
sudo reboot
Line 51: Line 65:
== Reporting Bugs Upstream ==
Unfortunately it is sometimes the case that bugs can still exist in the mainline kernel. The mainline kernel has their own bugtracking system at http://bugzilla.kernel.org . It would be helpful if you would also report your bug there. It is often the case that once a bug is escalated upstream there is a quick resolution through the help and support of the mainline kernel community. Bug reports in Launchpad can also be set up to monitor bugs reported in other bugtracking systems. The following steps should help you report your bug upstream and monitor it in Launchpad:
== Using Ubuntu Kernel Configuration ==
The basic instructions provided above work well if you are building your own custom kernel. However, if you want to build a kernel that matches the official Ubuntu kernel package configuration as much as possible a few extra steps are needed. Note that if you are simply trying to build the ubuntu kernel, you should be following the https://help.ubuntu.com/community/Kernel/Compile guide instead of this one.
Line 54: Line 68:
 1. Go to http://bugzilla.kernel.org
 1. Verify your bug does not already exist in the upstream bugtracking system.
  i. If it does exist, please add any useful information that may be lacking in the current report.
   * Link your Launchpad report to the upstream kernel bug report (see step 5).
  i. If your bug does not exist, proceed to the next step.
 1. Enter your bug report at http://bugzilla.kernel.org/enter_bug.cgi . Follow the instructions on that page.
 1. When creating your bug report be sure to _attach_ any relevant information. This will usually include:
  i. the version of the kernel you are running (uname -r)
  i. dmesg output.
  i. lspci -vvnn output.
  i. If the bug is about interrupts, then /proc/interrupts is also helpful.
  i. If a BIOS issue is suspected, dmidecode output is also helpful.
  i. If the bug is regarding memory oddities, /proc/mtrr info is also helpful.
  i. Most importantly, if this is a regression, the best information you can provide the kernel developers is the information from doing a git bisect. This will hopefully narrow down the exact patch that is causing the regression. The following link will help you through this process.
   * http://www.kernel.org/doc/local/git-quick.html#bisect
 1. After you've reported your bug to the kernel bugzilla, remember to set up your Launchpad bug report to monitor the upstream bugzilla report.
  i. On your Launchpad bug report page, look in the "Actions" area on the left hand side of the page.
  i. Click the "Also affects project" link.
  i. Enter the URL of your bugzilla report.
  i. Click the "Add to Bug Report" button.
  i. Your Launchpad report is now monitoring your upstream bugzilla report.
 1. Perform steps 1-7 above, use the Ubuntu kernel config in step 4
 1. Override the kernel-package default packaging scripts with the Ubuntu packaging scripts: {{{
cd $HOME
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-lucid.git
cp -a /usr/share/kernel-package ubuntu-package
cp ubuntu-lucid/debian/control-scripts/{postinst,postrm,preinst,prerm} ubuntu-package/pkg/image/
cp ubuntu-lucid/debian/control-scripts/headers-postinst ubuntu-package/pkg/headers/
}}}
 1. Build packages using overlay directory: {{{
cd $HOME/linux
CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) fakeroot make-kpkg --initrd --append-to-version=-custom --overlay-dir=$HOME/ubuntu-package kernel_image kernel_headers
}}}
 1. Perform steps 9-11 above.

Note: The "--overlay-dir" option is only available in Lucid or later. If you need to build a kernel on a previous distribution, either install a backport of kernel-package if available, or manually edit /usr/share/kernel-package as needed.

Many times patches for bugs are committed upstream but have yet to make their way down to the Ubuntu kernel. It is often helpful if users are able to verify if the upstream patches do indeed resolve the issue they are witnessing. Likewise, in the opposite situation, it is useful to know if a bug may still exist upstream.

The following document should help users build their own kernel from the upstream mainline kernel to help verify if a bug still exists or not. If a bug is still present in the upstream kernel, it is encouraged that the bug be reported upstream following the procedure noted in this page. Please note that the following steps are targeted towards Ubuntu users and focuses on building the mainline kernel from the git repository at http://git.kernel.org.

For building Ubuntu kernels please refer to https://help.ubuntu.com/community/Kernel/Compile.

Prerequisites

There are a few tools that are necessary in order to build your own kernel(s). The 'git' (or 'git-core' for 10.04 or before) package provides the git revision control system which will be used to clone the mainline git repository. The 'kernel-package' provides the make-kpkg utility which automatically build your kernel and generate the linux-image and linux-header .deb files which can be installed. You will need to install the following packages:

sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves

Kernel Build and Installation

  1. Change to the directory where you want to clone the git tree. In this example we will use $HOME:

    cd $HOME
  2. Clone the mainline kernel git tree:

    git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
  3. Change to directory linux:

    cd linux

    Info (!) If you only want to test all commits up to and including a specific one, instead of every commit you just downloaded, one may execute:

    git checkout COMMIT
    where COMMIT is the specific commit number (ex. 9587190107d0c0cbaccbf7bf6b0245d29095a9ae).
  4. Copy the kernel config file from your existing system to the kernel tree:

    cp /boot/config-$(uname -r) .config
  5. Bring the config file up to date. Answer any questions that get prompted. Unless you know you are interested in a particular feature, accepting the default option by pressing Enter should be a safe choice:

    make oldconfig

    In cases where your kernel source is significantly newer than the existing config file, you'll be presented with all of the new config options for which there is no existing config file setting. You can either sit there and keep hitting Enter to take the default (generally safe), or you can just run:

    make olddefconfig
    which will set all the new options to the default values without listing them all for your inspection.
  6. (optional) If you need to make any kernel config changes, do the following and save your changes when prompted:

    make menuconfig
  7. Clean the kernel source directory:

    make clean
  8. Build the linux-image and linux-header .deb files using a thread per core + 1. This process takes a lot of time:

    make -j $(getconf _NPROCESSORS_ONLN) deb-pkg LOCALVERSION=-custom

    With this command the package names will be something like linux-image-2.6.24-rc5-custom and linux-headers-2.6.24-rc5-custom, and in that case the version will be 2.6.24-rc5-custom-10.00.Custom. You may change the string "custom" into something else by changing the LOCALVERSION option.

  9. Change to one directory level up (this is where the linux-image and linux-header .deb files were put):

    cd ..

An alternative to build only binary packages is:

make -s -j$(getconf _NPROCESSORS_ONLN) olddefconfig bindeb-pkg LOCALVERSION=-custom 

which builds only binary packages, and uses a shortcut to use default settings for settings not included in .config.

  1. Now install the .deb files. In this example, the files are linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb and linux-headers-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb. You may receive warnings about '/lib/firmware/2.6.24-rc5-custom/' - this is expected and will only be problematic if the driver you are trying to test requires firmware:

    sudo dpkg -i linux-image-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb
    sudo dpkg -i linux-headers-2.6.24-rc5-custom_2.6.24-rc5-custom-10.00.Custom_i386.deb
  2. You are now ready to boot into your new kernel. Just make sure you select the new kernel when you boot:

    sudo reboot

Using Ubuntu Kernel Configuration

The basic instructions provided above work well if you are building your own custom kernel. However, if you want to build a kernel that matches the official Ubuntu kernel package configuration as much as possible a few extra steps are needed. Note that if you are simply trying to build the ubuntu kernel, you should be following the https://help.ubuntu.com/community/Kernel/Compile guide instead of this one.

  1. Perform steps 1-7 above, use the Ubuntu kernel config in step 4
  2. Override the kernel-package default packaging scripts with the Ubuntu packaging scripts:

    cd $HOME
    git clone git://kernel.ubuntu.com/ubuntu/ubuntu-lucid.git
    cp -a /usr/share/kernel-package ubuntu-package
    cp ubuntu-lucid/debian/control-scripts/{postinst,postrm,preinst,prerm} ubuntu-package/pkg/image/
    cp ubuntu-lucid/debian/control-scripts/headers-postinst ubuntu-package/pkg/headers/
  3. Build packages using overlay directory:

    cd $HOME/linux
    CONCURRENCY_LEVEL=$(getconf _NPROCESSORS_ONLN) fakeroot make-kpkg --initrd --append-to-version=-custom --overlay-dir=$HOME/ubuntu-package kernel_image kernel_headers
  4. Perform steps 9-11 above.

Note: The "--overlay-dir" option is only available in Lucid or later. If you need to build a kernel on a previous distribution, either install a backport of kernel-package if available, or manually edit /usr/share/kernel-package as needed.

KernelTeam/GitKernelBuild (last edited 2025-01-31 23:23:40 by tim-richardson)