特殊:Badtitle/NS100:Kernel/Compile/zh
![]() |
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/Kernel/Compile }} |
![]() |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/af | • {{#if: UbuntuHelp:Kernel/Compile|Afrikaans| [[::Kernel/Compile/zh/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ar | • {{#if: UbuntuHelp:Kernel/Compile|العربية| [[::Kernel/Compile/zh/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/az | • {{#if: UbuntuHelp:Kernel/Compile|azərbaycanca| [[::Kernel/Compile/zh/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/bcc | • {{#if: UbuntuHelp:Kernel/Compile|جهلسری بلوچی| [[::Kernel/Compile/zh/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/bg | • {{#if: UbuntuHelp:Kernel/Compile|български| [[::Kernel/Compile/zh/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/br | • {{#if: UbuntuHelp:Kernel/Compile|brezhoneg| [[::Kernel/Compile/zh/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ca | • {{#if: UbuntuHelp:Kernel/Compile|català| [[::Kernel/Compile/zh/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/cs | • {{#if: UbuntuHelp:Kernel/Compile|čeština| [[::Kernel/Compile/zh/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/de | • {{#if: UbuntuHelp:Kernel/Compile|Deutsch| [[::Kernel/Compile/zh/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/el | • {{#if: UbuntuHelp:Kernel/Compile|Ελληνικά| [[::Kernel/Compile/zh/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/es | • {{#if: UbuntuHelp:Kernel/Compile|español| [[::Kernel/Compile/zh/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/fa | • {{#if: UbuntuHelp:Kernel/Compile|فارسی| [[::Kernel/Compile/zh/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/fi | • {{#if: UbuntuHelp:Kernel/Compile|suomi| [[::Kernel/Compile/zh/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/fr | • {{#if: UbuntuHelp:Kernel/Compile|français| [[::Kernel/Compile/zh/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/gu | • {{#if: UbuntuHelp:Kernel/Compile|ગુજરાતી| [[::Kernel/Compile/zh/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/he | • {{#if: UbuntuHelp:Kernel/Compile|עברית| [[::Kernel/Compile/zh/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/hu | • {{#if: UbuntuHelp:Kernel/Compile|magyar| [[::Kernel/Compile/zh/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/id | • {{#if: UbuntuHelp:Kernel/Compile|Bahasa Indonesia| [[::Kernel/Compile/zh/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/it | • {{#if: UbuntuHelp:Kernel/Compile|italiano| [[::Kernel/Compile/zh/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ja | • {{#if: UbuntuHelp:Kernel/Compile|日本語| [[::Kernel/Compile/zh/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ko | • {{#if: UbuntuHelp:Kernel/Compile|한국어| [[::Kernel/Compile/zh/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ksh | • {{#if: UbuntuHelp:Kernel/Compile|Ripoarisch| [[::Kernel/Compile/zh/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/mr | • {{#if: UbuntuHelp:Kernel/Compile|मराठी| [[::Kernel/Compile/zh/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ms | • {{#if: UbuntuHelp:Kernel/Compile|Bahasa Melayu| [[::Kernel/Compile/zh/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/nl | • {{#if: UbuntuHelp:Kernel/Compile|Nederlands| [[::Kernel/Compile/zh/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/no | • {{#if: UbuntuHelp:Kernel/Compile|norsk| [[::Kernel/Compile/zh/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/oc | • {{#if: UbuntuHelp:Kernel/Compile|occitan| [[::Kernel/Compile/zh/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/pl | • {{#if: UbuntuHelp:Kernel/Compile|polski| [[::Kernel/Compile/zh/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/pt | • {{#if: UbuntuHelp:Kernel/Compile|português| [[::Kernel/Compile/zh/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ro | • {{#if: UbuntuHelp:Kernel/Compile|română| [[::Kernel/Compile/zh/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/ru | • {{#if: UbuntuHelp:Kernel/Compile|русский| [[::Kernel/Compile/zh/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/si | • {{#if: UbuntuHelp:Kernel/Compile|සිංහල| [[::Kernel/Compile/zh/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/sq | • {{#if: UbuntuHelp:Kernel/Compile|shqip| [[::Kernel/Compile/zh/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/sr | • {{#if: UbuntuHelp:Kernel/Compile|српски / srpski| [[::Kernel/Compile/zh/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/sv | • {{#if: UbuntuHelp:Kernel/Compile|svenska| [[::Kernel/Compile/zh/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/th | • {{#if: UbuntuHelp:Kernel/Compile|ไทย| [[::Kernel/Compile/zh/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/tr | • {{#if: UbuntuHelp:Kernel/Compile|Türkçe| [[::Kernel/Compile/zh/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/vi | • {{#if: UbuntuHelp:Kernel/Compile|Tiếng Việt| [[::Kernel/Compile/zh/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/yue | • {{#if: UbuntuHelp:Kernel/Compile|粵語| [[::Kernel/Compile/zh/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/zh | • {{#if: UbuntuHelp:Kernel/Compile|中文| [[::Kernel/Compile/zh/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/zh-hans | • {{#if: UbuntuHelp:Kernel/Compile|中文(简体)| [[::Kernel/Compile/zh/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:Kernel/Compile | UbuntuHelp:Kernel/Compile | {{#if: | :}}Kernel/Compile/zh}}/zh-hant | • {{#if: UbuntuHelp:Kernel/Compile|中文(繁體)| [[::Kernel/Compile/zh/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:Kernel/Compile|:Kernel/Compile/zh|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Kernel/Compile/zh/zh | | {{#ifexist: Kernel/Compile/zh/zh | | {{#ifeq: {{#titleparts:Kernel/Compile/zh|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Kernel/Compile/zh|1|-1|}} | zh | | }}
//*^*本人只是个自由软件爱好者,是个菜鸟,译错莫怪。
免责声明
'构建和使用一个定制的内核将使你的系统很难获得支持。'编译你自己的内核(kernel)只能算是一个学习过程,所以针对你自己编译出来的内核去提交 BUG 是不允许的(如果你这么做,他们就会拒绝这个 BUG,也不做任何解释)如果你有一个与 Ubuntu/Canonical 签订的商业支持合同,你的自编译内核也不会在这种合同支持的范围之内。另外还请注意,本页介绍的是针对 Edgy (2.6.17) 或以上版本的内核!直到这个内核源之前,我们没有任何到位的机制来使人们容易的编译他们自己的内核。我们是有意为之。本文并没有介绍如何编译来自于 kernel.org 的原始内核,而只是说明如何重建当前的 Ubuntu 内核源。
编译内核的原因
- 你是一个内核开发者。
- 你需要内核编译成一种特殊的方式,而官方内核并没有这样做(例如,使能一些实验功能)。
- 你正试图调试一个关于原Ubuntu内核你已经提交或即将提交的问题。
- 你有的硬件原Ubuntu的内核不支持。
不建议编译内核的情况
- 你只需要编译一个特殊的驱动。对于这种情况,你只需要安装linux-headers包。
- 你不知道在做什么,和你损坏了某一部分,你需要帮助修复它。依据你的错误情况,也许你最终需要重新安装你的系统。
- 你偶然接触到这篇文章,但是因为看上去有趣而被迷住。相信我,这一点都没趣。:)
如果你想要安装一个新的不需要编译的内核,你能使用Synaptic,,搜索你想要安装的linux-image和内核版本。
一个更容易的方法是点击System > Administration > Update Manager >点击Check按钮>接受包括kernel在内的所有更新。
你需要的工具
一开始,你需要安装一些新的包。
sudo apt-get install linux-kernel-devel fakeroot build-essential
这会安装与编译器有关的包和内核打包工具。它也安装这git-core包,它是与Ubuntu 内核源最好的交互方式。
获得内核源
这儿有几种获得内核源的方法:
- 使用git(你能找到详细说明在Kernel Git Guide) -这会使你总是保持与最新的Ubuntu内核源同步。
- 下载源文件存档-对于那些想要重建包括额外补丁的标准Ubuntu包的人,这是最简单和有用的,注意这几乎总是滞后于最新开发源,如果你需要带最新补丁的内核源,你应该使用git(选项1)。下载源文件的操作:
- 下载源码包(进一步的详细说明在这页下面AltBuildMethod Alternate Build Method: The Old-Fashioned Debian Way)-请注意这跟选项2不一样
sudo apt-get build-dep linux-source apt-get source linux-source
对于Hardy (8.04)版本,命令变为:
sudo apt-get build-dep linux-image-$(uname -r) apt-get source linux-image-$(uname -r)
修改你所需的内核源文件
对大多数人来说,简单的修改一下配置configs已经足够。如果你需要安装内核补丁,请阅读此补丁提供者的说明,已确定如何使用。 原Ubuntu configs是被安装在(debian/config/ARCH/)-ARCH目录是你刚刚建立的。在这个目录下有很多文件。这"config"文件是其架构中所有对象的基础。这儿有几个针对特定目标的config.FLAVOUR(config.xxx)。例如,下面是2.6.20,i386的文件:
ls -l debian/config/i386/ total 108 -rw-r--r-- 1 root src 73962 2007-08-13 01:29 config -rw-r--r-- 1 root root 1369 2007-08-13 01:29 config.386 -rw-r--r-- 1 root root 1330 2007-08-13 01:29 config.generic -rw-r--r-- 1 root root 1395 2007-08-13 01:29 config.server -rw-r--r-- 1 root root 1756 2007-08-13 01:29 config.server-bigiron -rw-r--r-- 1 root root 8 2007-08-13 01:25 lowlatency -rw-r--r-- 1 root root 194 2007-08-13 01:25 vars.386 -rw-r--r-- 1 root root 218 2007-08-13 01:25 vars.server-bigiron
如果你在debian/config中没有找到config配置文件,你会在/boot目录中找到它们,例如,/boot/config-2.6.22-14-generic。 如果你需要改变某一个配置选项,简单的修改包括这选项的文件。如果你修改"config"文件,会影响这结构中的所有对象。如果你修改其中一个对象配置,它仅仅影响此对象。 当你打了一个补丁,或者调整了配置之后,最好去重新生成配置文件以确保他们是一致的。 去重新生成所有的配置,请运行:
debian/rules updateconfigs
如果你仅仅想要更新一个配置,请运行:
debian/scripts/misc/oldconfig ARCH