|
Size: 2379
Comment:
|
Size: 3821
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| The following is a true idiot's guide - not for idiots, but written by an idiot - so please correct/extend/update as appropriate. | Short guide to build kernel |
| Line 3: | Line 3: |
| == Download == First of all we need to download the kernel sources. === Get Git === Git is the source code control system used in the kernel. You need to download and install it. |
== Default basic build == {{{ wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2 tar xjf linux-2.6.24.tar.bz2 cd linux-2.6.24 make defconfig make all su -c "make modules_install install" }}} |
| Line 8: | Line 13: |
| === Choose A Repository === The different kernel repositories are listed at [http://git.kernel.org/]. |
This installs the kernel to /boot/, modules to /lib/modules/2.6.24/ and updates file /boot/grub/grub.conf |
| Line 11: | Line 15: |
| I've no idea how you choose which one to use... | == Download Using a Distribution Kernel Source Code Package == The method of downloading the package will vary according to the distribution you are using, so you're pretty much on your own there. Note that the source code will probably be placed in a sub-directory under /usr/src. |
| Line 13: | Line 18: |
| Say, for example, we're using linux/kernel/git/linville/wireless-2.6.git. | When using this method you need to be very careful that your newly compiled kernel won't overwrite the existing one (or you might not be able to boot any more...). Most distributions keep the two separately, but you need to understand how your system boots, and how kernels are selected before going too far down this route. |
| Line 15: | Line 20: |
| === Download the Repository === Create a new directory (which can be under your home directory), and cd to it. |
== Download Using Git == Git is the source code control system used in the kernel. You need to download and install it. |
| Line 18: | Line 23: |
| Run git clone git://git.kernel.org/pub/scm/ + project path which in our example would be: git clone git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git |
Next you need to choose a repository. The different kernel repositories are listed at http://git.kernel.org/. Most new developers will be contributing to an existing project, so the best way to find out which is the correct repository is to go to the home page for that project, and look there. |
| Line 26: | Line 27: |
| You need to update the .config file in the root of your kernel tree. You can edit the text file directly, or more likely run "make xconfig" as thsi will give you the help text for each option as well. | You need to update the .config file in the root of your kernel tree to specify which facilities/drivers are built into the kernel. |
| Line 28: | Line 29: |
| Your running kernel should have a config.version file in /boot which may be a good reference for individual settings, but be wary of using it "as is" as the new kernel may have added new parameters. | If you have used your distribution's source code distribution then it may have come with a suitably configured .configure. Alternatively there may be a suitable configure file in /boot that you can use with |
| Line 30: | Line 31: |
| If you are running on a system with a SATA interface disk, then the default kernel configuration probably won't build. You'll need to convert some device drivers from modules to being compiled into the kernel. | {{{ cp /boot/config-`uname -r` .config make oldconfig }}} |
| Line 32: | Line 36: |
| If you're using a tarball, or git to get the source code, then using an old .config file is a bit risky as it may not have all the new options defined for the new version of the kernel. You probably need to fall back on editing whatever .config came with your sourcode using either {{{make xconfig}}} or {{{make gconfig}}} depending on which one runs on your system. | |
| Line 33: | Line 38: |
| === Build the Kernel === make && sudo make install |
If you are running on a system with a SATA interface disk, then the default kernel configuration probably won't build. You'll need to convert some device drivers from modules to being compiled into the kernel. |
| Line 37: | Line 41: |
| You need to configure your boot system to make the new kernel one of the options. You probably don't want it to be the default at this stage. | You need to configure your boot system to make the new kernel one of the options. You probably don't want it to be the default at this stage. |
| Line 40: | Line 44: |
| The build should have installed the kernel in /boot and told you what it's called. If you're using grub, you now need to edit /boot/grub/menu.lst to add it to the list of possible kernels to boot from. | The build should have installed the kernel in /boot and told you what it's called. If you're using grub, you now need to edit /boot/grub/menu.lst to add it to the list of possible kernels to boot from. |
| Line 43: | Line 47: |
| title My development kernel root /dev/sda1 kernel /boot/vmlinuz-2.6.24-rc3 root=/dev/sda1 ro |
{{{ title My development kernel root /dev/sda1 kernel /boot/vmlinuz-2.6.24-rc3 root=/dev/sda1 ro }}} |
| Line 49: | Line 56: |
| == Test == === Run the Kernel === Reboot, and select your development kernel from the list of kernels. |
On Debian based systems, running {{{update-grub}}} regenerates the grub configuration based on kernels found in /boot. |
| Line 53: | Line 58: |
| === Useful Commands === dmesg will print out the kernel's ring buffer of trace messages. |
== more == * [http://lxr.free-electrons.com/source/README#050 linux/README] * '''Linux Kernel in a Nutshell''' by Greg Kroah-Hartman, http://www.kroah.com/lkn/, online: [http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ html] * [http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html Kernel Rebuild Guide], Kwan Lowe, 2004 * in Debian * [http://www.debian.org/doc/FAQ/ch-kernel.en.html Debian and the kernel, FAQ] * [http://www.debian.org/doc/manuals/reference/ch-kernel.en.html The Linux kernel under Debian, Reference] * http://kernel-handbook.alioth.debian.org/ |
Short guide to build kernel
Default basic build
wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2 tar xjf linux-2.6.24.tar.bz2 cd linux-2.6.24 make defconfig make all su -c "make modules_install install"
This installs the kernel to /boot/, modules to /lib/modules/2.6.24/ and updates file /boot/grub/grub.conf
Download Using a Distribution Kernel Source Code Package
The method of downloading the package will vary according to the distribution you are using, so you're pretty much on your own there. Note that the source code will probably be placed in a sub-directory under /usr/src.
When using this method you need to be very careful that your newly compiled kernel won't overwrite the existing one (or you might not be able to boot any more...). Most distributions keep the two separately, but you need to understand how your system boots, and how kernels are selected before going too far down this route.
Download Using Git
Git is the source code control system used in the kernel. You need to download and install it.
Next you need to choose a repository. The different kernel repositories are listed at http://git.kernel.org/. Most new developers will be contributing to an existing project, so the best way to find out which is the correct repository is to go to the home page for that project, and look there.
Compile
Configure the Kernel
You need to update the .config file in the root of your kernel tree to specify which facilities/drivers are built into the kernel.
If you have used your distribution's source code distribution then it may have come with a suitably configured .configure. Alternatively there may be a suitable configure file in /boot that you can use with
cp /boot/config-`uname -r` .config make oldconfig
If you're using a tarball, or git to get the source code, then using an old .config file is a bit risky as it may not have all the new options defined for the new version of the kernel. You probably need to fall back on editing whatever .config came with your sourcode using either make xconfig or make gconfig depending on which one runs on your system.
If you are running on a system with a SATA interface disk, then the default kernel configuration probably won't build. You'll need to convert some device drivers from modules to being compiled into the kernel.
Configure the Boot System
You need to configure your boot system to make the new kernel one of the options. You probably don't want it to be the default at this stage.
Grub
The build should have installed the kernel in /boot and told you what it's called. If you're using grub, you now need to edit /boot/grub/menu.lst to add it to the list of possible kernels to boot from.
You need an entry something like:
title My development kernel
root /dev/sda1
kernel /boot/vmlinuz-2.6.24-rc3 root=/dev/sda1 roroot=UUID options don't seem to work at this stage.
On Debian based systems, running update-grub regenerates the grub configuration based on kernels found in /boot.
more
[http://lxr.free-electrons.com/source/README#050 linux/README]
Linux Kernel in a Nutshell by Greg Kroah-Hartman, http://www.kroah.com/lkn/, online: [http://www.linuxtopia.org/online_books/linux_kernel/kernel_configuration/ html]
[http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html Kernel Rebuild Guide], Kwan Lowe, 2004
- in Debian
[http://www.debian.org/doc/FAQ/ch-kernel.en.html Debian and the kernel, FAQ]
[http://www.debian.org/doc/manuals/reference/ch-kernel.en.html The Linux kernel under Debian, Reference]