Build Your Own Kernel
2016-09-07 11:18
183 查看
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.
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.
the apt-get source <package> command. For example to obtain the source
for the currently running kernel you can use the command:
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.
For example to obtain the precise tree:
This takes the current configuration for each architecture/flavour supported and calls menuconfig to edit its config file. The chmod is needed because the way the source package is created, it loses the executable bits on the scripts.
In order to make your kernel "newer" than the stock Ubuntu kernel from which you are based you should add a local version modifier. Add something like "+test1" to the end of the first version number in the
debian.master/changelog file, before building. This will help identify your kernel when running as it also appears in
uname -a. Note that when a new Ubuntu kernel is released that will be newer than your kernel (which needs regenerating), so care is needed when upgrading. NOTE: do not attempt to use CONFIG_LOCALVERSION as this _will_ break the build.
of the kernel source tree and then type the following commands:
If the 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 (or four)
.deb packages would be produced:
on later releases you will also find a linux-extra- package which you should also install if present.
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 twomain 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 usingthe 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 foreach 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 codename>.git
For example to obtain the precise tree:
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.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)
Modifying the configuration
This step can be skipped if no configuration changes are wanted. The build process will use a configuration that is put together from various sub-config files. The simplest way to modify anything here is to run:chmod a+x debian/rules chmod a+x debian/scripts/* chmod a+x debian/scripts/misc/* fakeroot debian/rules clean fakeroot debian/rules editconfigs # you need to go through each (Y, Exit, Y, Exit..) or get a complaint about config later
This takes the current configuration for each architecture/flavour supported and calls menuconfig to edit its config file. The chmod is needed because the way the source package is created, it loses the executable bits on the scripts.
In order to make your kernel "newer" than the stock Ubuntu kernel from which you are based you should add a local version modifier. Add something like "+test1" to the end of the first version number in the
debian.master/changelog file, before building. This will help identify your kernel when running as it also appears in
uname -a. Note that when a new Ubuntu kernel is released that will be newer than your kernel (which needs regenerating), so care is needed when upgrading. NOTE: do not attempt to use CONFIG_LOCALVERSION as this _will_ break the build.
Building the kernel
Building the kernel is quite easy. Change your working directory to the rootof the kernel source tree and then type the following commands:
fakeroot debian/rules clean fakeroot debian/rules binary-headers binary-generic
If the 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 (or four)
.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
on later releases you will also find a linux-extra- package which you should also install if present.
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
Debug Symbols
Sometimes it is useful to have debug symbols built as well. Two additional steps are needed. First pkg-config-dbgsym needs to be installed. Second when executing the binary-* targets you need to add 'skipdbg=false'.sudo apt-get install pkg-config-dbgsym
fakeroot debian/rules clean fakeroot debian/rules binary-headers binary-generic skipdbg=false
相关文章推荐
- Build a mediawiki site on your own computer
- How To Build Your Own IPTV-VoD System
- How to Write Your Own Linux Kernel Module with a Simple Example
- Build your own cryptographically safe server/client protocol
- Build Your Own Security Lab: A Field Guide for Network Testing
- Build Your Own PaaS with Docker.pdf
- build-your-own-promise 构建自己的promise
- Build Your Own Oracle RAC 10g Release 2 Cluster on Linux and FireWire
- Fedora: Compile your own kernel
- Reading Build your own CAB (1) -- Jeremy D. Miller
- 在fedora14下安装vmware 7.1.4 build-385536 出现C header files matching your running kernel were not found. 错误
- your system does not seem to be set up to build kernel modules
- Build Your Own Oracle RAC Cluster on Oracle Enterprise Linux and iSCSI
- XamlReader.Load(): Build Up Your Own XamlPad
- Build Your Own Images
- [Codecademy] HTML&CSS 第二课:Build Your Own Webpage
- Milestone/A853/XT702/umts_sholes Compile your own Android ROM and Customize your own linux kernel
- Mesos + Docker Tutorial: How to Build Your Own Fra
- Build Your Own Website
- HOWTO_build_your_own_module