KernelCustomBuild

Differences between revisions 1 and 16 (spanning 15 versions)
Revision 1 as of 2006-06-14 23:26:15
Size: 4925
Editor: 72
Comment: Custom kernel build howto
Revision 16 as of 2006-10-30 23:12:33
Size: 6536
Editor: host81-152-37-34
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Build or using custom kernels will pretty much lose any ability to get support for your system. You will not be allowed to file bugs on the custom built kernel (if you do, they will be Rejected without explanation). Building and using a custom kernel will make it very difficult to get support for your system. You will not be allowed to file bugs on the custom-built kernel (if you do, they will be Rejected without explanation).
Line 7: Line 7:
Also note that this page describes how to do things for the edgy (2.6.17) kernel and newer! Until this kernel source, we did not have in place any mechanisms that would allow people to build their own kernels easily. This was intentional. Also note that this page describes how to do things for the Edgy (2.6.17) kernel and newer! Until this kernel source, we did not have any mechanisms in place that would allow people to build their own kernels easily. This was intentional.
Line 15: Line 15:
 * You need the kernel compiled in a special way, that the official kernel cannot be compiled in (for example, with some experimental feature enabled).
 * You are attempting to debug a problem for which you have or will file a bug report on the stock Ubuntu kernel.
 * You need the kernel compiled in a special way, that the official kernel is not compiled in (for example, with some experimental feature enabled).
 * You are attempting to debug a problem for which you have filed or will file a bug report on the stock Ubuntu kernel.
Line 28: Line 28:
To start, you will need to install a few packages. Luckily, all of them can be installed at once using a single meta-package: To start, you will need to install a few packages.
Line 31: Line 31:
sudo apt-get install linux-kernel-devel sudo apt-get install linux-kernel-devel fakeroot kernel-wedge kernel-package
Line 34: Line 34:
This will install the compiler and related packages. It will also install the git-core package, which is the best way to interact with the Ubuntu kernel source. This will install the compiler related packages and kernel packaging tools. It will also install the git-core package, which is the best way to interact with the Ubuntu kernel source.
Line 39: Line 39:
There are two ways to obtain the Ubuntu kernel source. The most prefered way it to use git. Detailed instructions for using git can be found in KernelGitGuide. There are two ways to obtain the Ubuntu kernel source. The prefered way is to use git. Detailed instructions for using git can be found in KernelGitGuide.
Line 44: Line 44:
sudo apt-get install linux-source-2.6.17 sudo apt-get install linux-source
Line 47: Line 47:
However, this will almost always be out of date. Using git allows you to always stay in sync with the latest Ubuntu kernel source.
This will give you the source to the latest avalible kernel. However, this will almost always be out of date compared to the latest development source. Using git allows you to always stay in sync with the latest Ubuntu kernel source.
Line 60: Line 59:
-rw-r--r-- 1 me me  1859 Jun 12 14:59 config.386
-rw-r--r-- 1 me me  1394 Jun 12 14:59 config.686
-rw-r--r-- 1 me me  1420 Jun 12 14:59 config.k7
-rw-r--r-- 1 me me  1519 Jun 12 14:59 config.server
-rw-r--r-- 1 me me  1867 Jun 12 14:59 config.server-bigiron
-rw-r--r-- 1 me me 1859 Jun 12 14:59 config.386
-rw-r--r-- 1 me me 1394 Jun 12 14:59 config.686
-rw-r--r-- 1 me me 1420 Jun 12 14:59 config.k7
-rw-r--r-- 1 me me 1519 Jun 12 14:59 config.server
-rw-r--r-- 1 me me 1867 Jun 12 14:59 config.server-bigiron
Line 68: Line 67:

Note: If you do not find the config files there, you may find them in your /boot directory. For instance:

/boot/config-2.6.15-23-386

After applying a patch, or adjusting the configs, it is always best to regenerate the config files to ensure they are consistent. There is a helper command for this. To regenerate all architectures run:

{{{
debian/rules updateconfigs
}}}

If you just want to update one architecture, run:

{{{
debian/bin/oldconfig ARCH
}}}
Line 80: Line 95:
The ''AUTOBUILD'' environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated for the git HEAD SHA. If not, it is generated from the uuidgen program. Your packages will be named using this ID. The ''AUTOBUILD'' environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated from the git HEAD SHA. If not, it is generated from the uuidgen program (which means every time you execute the debian/rules build, the UUID will be different!). Your packages will be named using this ID.
Line 90: Line 105:
The debs are placed in ubuntu-2.6/debian/build.
Line 93: Line 109:
Now that the build is complete, you can install the generated deb's using dpkg: Now that the build is complete, you can install the generated debs using dpkg:
Line 101: Line 117:

-are we supposed to just use module-assistant? any plans to add this info? thanks, MattPrice

'''Q:''' What about custom install and netboot images (and their initrd etc)?, PeterMagnusson

'''A:'''


'''Q:''' What directory are you in when you run these commands
ls -l debian/config/i386/
I'm sure you mean to untar the kernel source you just downloaded and cd into that tree (cd /usr/src ; tar xf linux-source-2.6.17.tar.bz2 ; cd linux-source-2.6.17) but there is no directory debian/config/i386 in there.
debian/Config has .config files in it, but no bigiron file so i dono where that kernel comes from? EliCriffield

'''A:'''
Maybe he meant debian/Config?

'''A2:'''
On 6.06, the linux-source package does not include the debian directory, it seems. You need to install the source package for linux-image, with a command like

sudo apt-get source linux-image-2.6.15-27-386

SteveEdmondson
 

Disclaimer

Building and using a custom kernel will make it very difficult to get support for your system. You will not be allowed to file bugs on the custom-built kernel (if you do, they will be Rejected without explanation).

If you have a commercial support contract with Ubuntu/Canonical, this will void such support.

Also note that this page describes how to do things for the Edgy (2.6.17) kernel and newer! Until this kernel source, we did not have any mechanisms in place that would allow people to build their own kernels easily. This was intentional.

This page does NOT describe how to build stock kernels from kernel.org. This is how to rebuild the actual Ubuntu kernel source.

Reasons for compiling a custom kernel

  • You are a kernel developer.
  • You need the kernel compiled in a special way, that the official kernel is not compiled in (for example, with some experimental feature enabled).
  • You are attempting to debug a problem for which you have filed or will file a bug report on the stock Ubuntu kernel.

Reasons for NOT compiling a custom kernel

  • You merely need to compile a special driver. For this, you only need to install the linux-headers packages.
  • You have no idea what you are doing, and if you break something, you'll need help fixing it. If you hose your box, reinstall. Don't bother asking for help.
  • You got to this page by mistake, but checked it out because it looked interesting. Believe me, this isn't interesting at all Smile :)

What you'll need

To start, you will need to install a few packages.

sudo apt-get install linux-kernel-devel fakeroot kernel-wedge kernel-package

This will install the compiler related packages and kernel packaging tools. It will also install the git-core package, which is the best way to interact with the Ubuntu kernel source.

How to get the kernel source

There are two ways to obtain the Ubuntu kernel source. The prefered way is to use git. Detailed instructions for using git can be found in KernelGitGuide.

The other way is to simply:

sudo apt-get install linux-source

This will give you the source to the latest avalible kernel. However, this will almost always be out of date compared to the latest development source. Using git allows you to always stay in sync with the latest Ubuntu kernel source.

Modifying the source for your needs

For most people, simply modifying the configs is enough. If you need to install a patch, read the instructions from the patch provider for how to apply.

The stock Ubuntu configs are located in debian/config/ARCH/ where ARCH is the architecture you are building for. In this directory are several files. The config file is the base for all targets in that architecture. Then there are several config.FLAVOUR files that contain options specific to that target. For example, here are the files for 2.6.17, i386:

$ ls -l debian/config/i386/
total 88
-rw-r--r-- 1 me me 62737 Jun 14 18:31 config
-rw-r--r-- 1 me me 1859 Jun 12 14:59 config.386
-rw-r--r-- 1 me me 1394 Jun 12 14:59 config.686
-rw-r--r-- 1 me me 1420 Jun 12 14:59 config.k7
-rw-r--r-- 1 me me 1519 Jun 12 14:59 config.server
-rw-r--r-- 1 me me 1867 Jun 12 14:59 config.server-bigiron

If you need to change a config option, simply modify the file that contains the option. If you modify just the config file, it will affect all targets for this architecture. If you modify one of the target files, it only affects that target.

Note: If you do not find the config files there, you may find them in your /boot directory. For instance:

/boot/config-2.6.15-23-386

After applying a patch, or adjusting the configs, it is always best to regenerate the config files to ensure they are consistent. There is a helper command for this. To regenerate all architectures run:

debian/rules updateconfigs

If you just want to update one architecture, run:

debian/bin/oldconfig ARCH

Building the kernel

To build the kernel(s) is very simple. Depending on your needs, you may want to build all the kernel targets, or just one specific to your system. However, you also want to make sure that you do not clash with the stock kernels.

Use this command to build all targets for the architecture you are buidling on:

AUTOBUILD=1 fakeroot debian/rules binary-debs

The AUTOBUILD environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated from the git HEAD SHA. If not, it is generated from the uuidgen program (which means every time you execute the debian/rules build, the UUID will be different!). Your packages will be named using this ID.

To build a specific target, use this command:

AUTOBUILD=1 fakeroot debian/rules binary-debs flavours=k7

This will only build the AMD k7 variant of the i386 architecture.

The debs are placed in ubuntu-2.6/debian/build.

When it's done

Now that the build is complete, you can install the generated debs using dpkg:

sudo dpkg -i linux-image-2.6.17-2-ef427c-k7_2.6.17-2.2_i386.deb
sudo dpkg -i linux-headers--2.6.17-2-ef427c-k7_2.6.17-2.2_i386.deb

If you use modules from linux-restricted-modules, you will need to recompile this against your new linux-headers package. Details on how to do this will be added later.

-are we supposed to just use module-assistant? any plans to add this info? thanks, MattPrice

Q: What about custom install and netboot images (and their initrd etc)?, PeterMagnusson

A:

Q: What directory are you in when you run these commands ls -l debian/config/i386/ I'm sure you mean to untar the kernel source you just downloaded and cd into that tree (cd /usr/src ; tar xf linux-source-2.6.17.tar.bz2 ; cd linux-source-2.6.17) but there is no directory debian/config/i386 in there. debian/Config has .config files in it, but no bigiron file so i dono where that kernel comes from? EliCriffield

A: Maybe he meant debian/Config?

A2: On 6.06, the linux-source package does not include the debian directory, it seems. You need to install the source package for linux-image, with a command like

sudo apt-get source linux-image-2.6.15-27-386

SteveEdmondson


CategoryKernel

KernelCustomBuild (last edited 2011-03-13 19:14:33 by 84-73-137-162)