查看“内核编译指南”的源代码
来自Ubuntu中文
←
内核编译指南
跳到导航
跳到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 内核编译指南 == ---- 原文出处: 原文作者: 授权许可: 翻译人员:firehare 校对人员: 贡献者: 适用版本: 文章状态:完成 ---- Intro 介绍 This page tells how to rebuild the Ubuntu Linux kernel package. This is the most straightforward way of compiling your own Ubuntu kernel, but it's also rather heavyweight. If you plan on doing any kernel developing or debugging, you'd probably be happier following the KernelByHandHowto. It's a bit more involved, but a lot more flexible. 本页谈论如何重建Ubuntu Linux内核包。这是自己编译Ubuntu内核最直接的方法,但它也是相当重量级的方法。如果你打算做一些内核开发或调试的话,你也许会更高兴地按照本指南来做。它更复杂一点但也更灵活。 Setup 安装 We will build everything in the "linux" directory (or whatever you want to call it) in your home directory. The steps that must be run as root are prefixed by "sudo". 我们将在你用户目录中构建“Linux”目录下的任何东西(或是你想调用的)。下面的步骤必须做为根用户(通过前面用"sudo")来运行。 <pre><nowiki> $ sudo apt-get build-dep linux-source-2.6.8.1 $ mkdir ~/linux $ cd ~/linux $ apt-get source linux-source-2.6.8.1 $ cd linux-source-2.6.8.1-2.6.8.1 </nowiki></pre> Note that this technique can take a lot of disk space, especially if you don't disable any flavours (see below). My tree, with all flavours enabled, takes up 1.6 GB. It might take even more disk space during the compile. 注意:这种方式需要很大的磁盘空间,尤其是在你想要一些特色时(看下面)。My tree在实现全部特色时,需要1.6G。它可能在编译期间甚至需要更多的磁盘空间。 Configure 配置 At this point, you may want to change your kernel's configuration. Modify the appropriate file in debian/config/ARCH/ (i.e., if my current kernel is named "linux-image-2.6.8.1-3-686", I would edit debian/config/i386/686). 到这一步,你也许想改变你的内核配置。在debian/config/ARCH/(比如我当前的内核是“linux-image-2.6.8.1-3-686”,那么我将编辑debian/config/i386/686)目录中修改相应的文件。 You will probably also want to delete the other configurations that you don't care about. Or, at least, move them into another directory. Otherwise, you'll build every flavour from scratch -- a very time consuming process. The following example disables every flavour except for 686. 你可能也想删除其它那些你不关心的配置。或者至少将它们移到另一个目录中。否则,你将从头构建每一个--这是一个非常耗时的过程。下面的示例就是就是除了686之外,不构建任何特色。 <pre><nowiki> $ cd debian/config/i386 $ mkdir disabled $ mv * disabled $ mv disabled/686 . </nowiki></pre> Build 构建 Now that the source is installed and configured, build it. If you didn't limit the flavours above, this could take a very long time (about 7 hours on my 1 GHz? laptop). 现在源已经被安装和配置好了,构建它。如果你不对上述特色进行限制的话,它需要花费相当长的时间(在我的1Ghz的本本上花了大约七小时)。 -B says to only create the architecture-dependent binary files, and -uc and -us say that the files shouldn't be cryptographically signed. -rfakeroot allow you to do everything as a regular (non-root) user. -B 是说只构建依赖结构的两进制文件,-uc和-us 是指这些文件不能被加密,-rfakerroot 允许你作为一般(非根)用户去做任何事。 <pre><nowiki> $ cd ~/linux/linux-source-2.6.8.1-2.6.8.1 $ dpkg-buildpackage -B -uc -us -rfakeroot </nowiki></pre> Install 安装 Now install the brand new package. 现在安装新的包 <pre><nowiki> $ cd ~/linux $ sudo dpkg -i linux/linux-image-2.6.8.1-3-686_2.6.8.1-16_i686.deb </nowiki></pre> Build Link 构建链接 If you are going to build any out-of-tree 2.6 drivers, they will probably require links to the build environment from /lib/modules. You will need to set these up by hand. Of course, replace USER with your user name, or otherwise enure that you specify a full path to the linux directory you used to build the package. 如果你打算构建一些额外的2.6驱动,它们可能要求从/lib/modues链接到构建环境里。你需要手动设置它们。当然用你的用户名重置USER,否则请确实指定你用来构建包的Linux目录的绝对路径。 <pre><nowiki> $ sudo ln -s /home/USER/linux/linux-source-2.6.8.1-2.6.8.1/debian/build/build-686 /lib/modules/2.6.8.1-3-686/build $ sudo ln -s /home/USER/linux/linux-source-2.6.8.1-2.6.8.1/debian/build/build-686 /lib/modules/2.6.8.1-3-686/source </nowiki></pre> Bootloader 启动引导 You should set up your bootloader as recommended in the Bootloader section of the KernelCompileHowto. 你将设置你的启动引导,就象KernelCompileHowto中启动引导那节所建议的那样。 Reboot 重启 And reboot the computer! 然后重启计算机 Questions 问题 What about revisions numbers? When building with make-kpkg, you can use --revision=custom.xx to create your custom kernel revision. 什么是修订版本号?当用make-kpkg构建时,你可以有--revision=custom.xx来创建你们自定义内核修订版本。 How revisions are handled using this method? 通过这种方式怎样处理修订版本? How to handle ABI changes? 怎样处理ABI改变? --mukesh agrawal, Sat, 14 May 2005 19:28:29 +0100 I tried building a kernel by following the above instructions. But the kernel had some ABI changes (I disabled the kernel's loop block device support, so that I could build loop-aes). The build system spit out the following error 我尝试按上面的介绍来构建内核。但内核有一些ABI的改变(我使内核的环回块设备支持无效,以便我可以建构loop-aes)。构建系统显示下列错误: "ABI has changed! Refusing to continue; please update the ABINAME accordingly. Differences:" “ABI被改动!不能继续;请更新相应的ABINAME。不同之处:” but didn't give any hint on where/how to change the ABINAME. I tried what seemed like the most obvious thing (editing debian/abi/<kernel-version>/abiname), but that edit seems to have been clobbered by the build system. 但没有给出任何的关于在哪里和怎样改动ABINAME。我试了很多似乎是最明显的地方(编辑debian/abi/<kernel-version>/abiname),但编辑之事对编译系统无效。 Editing .config --mukesh agrawal, Sat, 14 May 2005 19:34:19 +0100 编辑.config --mukesh agrawal, Sat, 14 May 2005 19:34:19 +0100 AFAIK, this build process doesn't let you run make config in the build tree. So is the recommended approach to run make config in your own tree, and then copy the .config file over? (Editing .config by hand seems like a bad idea.) 就我所知,该处理过程并非让你在构建树中运行make config。而是建议在你自己的树中作近似处理,然后拷贝并覆盖.config文件?(手动编辑.config看上去并不是好的办法) Build Process --mukesh agrawal, Sat, 14 May 2005 19:36:40 +0100 构建处理 --mukesh agrawal, Sat, 14 May 2005 19:36:40 +0100 Seems like this build process always cleans out the tree before building. Could someone confirm, and add a note to this effect? Because the build time is so long for the Ubuntu .config, it is useful to know beforehand that you really need to get your source and .config the way you want them before building. The document currently hints at this, by saying the process is "heavyweight", but I think stating this explicitly would be useful. 该构建过程总是在构建之前清理树的。有人能对该效果进行确认和添加记录吗?因为构建Ubuntu的.config文件的时间相当长,它对于你在构建前预先知道如何如你所愿地得到你的源和.config文件来说是十分有用的。本文档也提示了这一点,说该过程是“重量级的”,但我想明确地说明这一点也将是有帮助的。
返回
内核编译指南
。
导航菜单
页面操作
页面
讨论
阅读
查看源代码
历史
页面操作
页面
讨论
更多
工具
个人工具
登录
导航
首页
最近更改
随机页面
页面分类
帮助
搜索
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息