BuildYourOwnKernel

Differences between revisions 14 and 15
Revision 14 as of 2010-11-19 18:36:17
Size: 3040
Editor: pool-98-108-155-157
Comment:
Revision 15 as of 2011-03-22 00:33:35
Size: 3465
Editor: c-98-234-57-120
Comment: add 'binary-headers' to the recommended build targets; explain specifically how to check and install the resulting set of three .debs.
Deletions are marked like this. Additions are marked like this.
Line 68: Line 68:
fakeroot debian/rules binary-generic fakeroot debian/rules binary-headers binary-generic
}}}

If build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version "2.6.38-7.37" on an amd64 system, these three .deb packages would be produced:

    {{{
cd ..
ls *.deb
    linux-headers-2.6.38-7_2.6.38-7.37_all.deb
    linux-headers-2.6.38-7-generic_2.6.38-7.37_amd64.deb
    linux-image-2.6.38-7-generic_2.6.38-7.37_amd64.deb
Line 73: Line 83:
If build is successful, the directory above your current will contain .deb files. Install and reboot - you'll at least need the one starting with "linux-image", and many cases also the one starting with "linux-headers" as well. Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:

    {{{
sudo dpkg -i linux*2.6.38-7.37*.deb
sudo reboot
}}}
Line 77: Line 92:
The above instructions provide a very simple recepie for obtaining the sources The above instructions provide a very simple recipe for obtaining the sources

This page will describe how to easily build the kernel.

The majority of users that are interested in building their own kernel are doing so because they have installed Ubuntu on their system and they wish to make a small change to the kernel for that system. In many cases the user just wants to make a kernel configuration change.

The purpose of this page is to give that user a minimum amount of information for them to meet the goal of making a simple change to the kernel, building it and installing their kernel. It is not intended to be the definitive guide to doing Ubuntu kernel development.

Obtaining the source for an Ubuntu release

There are a number of different ways of getting the kernel sources. The two main ways will be documented here.

If you have installed a version of Ubuntu and you want to make changes to the kernel that is installed on your system, use the apt-get method (described below) to obtain the sources.

However, if you wish to get the most up to date sources for the Ubuntu release you are running and make changes to that, use the git method (described below) to obtain the sources.

apt-get

The source code which generated a specific binary package may be obtained using the apt-get source <package> command. For example to obtain the source for the currently running kernel you can use the command:

  • apt-get source linux-image-$(uname -r)

git

All of the Ubuntu Kernel source is maintained under git. The source for each release is maintained in its own git repository on kernel.ubuntu.com. To obtain a local copy you can simply git clone the repository for the release you are interested in as shown below.

  • git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<release>.git

For example to obtain the maverick tree:

  • git clone git://kernel.ubuntu.com/ubuntu/ubuntu-maverick.git

Build Environment

If you've not built a kernel on your system before, there are some packages needed before you can successfully build. You can get these installed with:

  • sudo apt-get build-dep linux-image-$(uname -r)

Building the kernel

Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:

  • fakeroot debian/rules clean
    fakeroot debian/rules binary-headers binary-generic

If build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version "2.6.38-7.37" on an amd64 system, these three .deb packages would be produced:

  • cd ..
    ls *.deb
        linux-headers-2.6.38-7_2.6.38-7.37_all.deb
        linux-headers-2.6.38-7-generic_2.6.38-7.37_amd64.deb
        linux-image-2.6.38-7-generic_2.6.38-7.37_amd64.deb

Testing the new kernel

Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:

  • sudo dpkg -i linux*2.6.38-7.37*.deb
    sudo reboot

See also

The above instructions provide a very simple recipe for obtaining the sources and then building them. If you are going to be doing more kernel development than simple configuration changes you may want to look at:

Git the source

Kernel/BuildYourOwnKernel (last edited 2024-01-25 18:52:39 by mhcerri)