内核编译及问题

本文详细介绍如何从源代码编译Linux内核,包括下载源代码、安装必要工具、配置及编译步骤,并针对编译过程中可能出现的问题提供了解决方案。

编译Linux内核

一、下载 linux 内核源代码

1.0  www.kernel.com 下载源代码

2.0  将下载的源程序解压到 /usr/src 内

二、下载工具

2.0  下载 build-essential:apt-get install build-essential

2.1  下载 libqt3-header:apt-get install libqt3-header

2.2  下载 gcc:apt-get install gcc

备注:如果不下载,后面的 make xconfig 将提示:没有规则可以创建

三、配置并编译

进入 /usr/src 目录,以下操作都是在该目录下进行:

3.0  make xconfig 配置 linux 内核信息,如果需要在嵌入式中装 linux 这点很重要。

详见:http://lamp.linux.gov.cn/Linux/kernel_options.html 讲解了内核配置

3.1  make clean (当源被重新编译需要执行)

3.2  make

3.3 make modules_install

3.4 cp /arch/i386/boot/bzImage /boot/vmlinuz-<version>

3.5  cp System.map /boot/System.map

3.6   mkinitramfs -o /boot/initrd.img-<version> <version>

3.7 修改 /boot/grub/grub.cfg

Reboot 

 

四、遇到问题

4.0  No rule to make target `xxx‘. 没有规则可以创建目标** ”解释为:

This means that make decided it needed to build a target, but then couldn’t find any instructions in the makefile on how to do that, either explicit or implicit (including in the default rules database).

If you want that file to be built, you will need to add a rule to your makefile describing how that target can be built. Other possible sources of this problem are typos in the makefile (if that filename is wrong) or a corrupted source tree (if that file is not supposed to be built, but rather only a prerequisite).

4.1  bzImage (中间 I 是大写的 i,不是小写的 L)很多人都写错了

4.2 如果发现自己的 /boot/grub 内没有 menu.lst ,修改 grub.conf 也是一样的

4.3  重启后遇到“Could not load /lib/modules/2.6.39.4/modules.dep ”但实际进去看后,该文件存在,这是因为 initrd.img-<version> 没有生成好,删除原来的文件 initrd.img-<version> update-initrdramfs –c –k 2.6.39.4 重新生成

4.4  中间make xconfig提示没有规则创建 xconfig这是因为 libqt3-header 没有安装,需要先更新源文件服务器,apt-get update 更新源文件,再下载即可

4.5 mkinitrd 是 RedHat 独有的,在编译其他内核时,应该采用 mkinitramfs 命令

五、参考

5.0 http://www.sudu.cn/info/html/edu/20080428/302845.html  内容不错,就是内核老了点

5.1  http://www.linuxforums.org/forum/kernel/55612-mini-howto-compile-linux-kernel-2-6-a.html  这里讲的更详细一些,并且给出了最小配置

5.2  http://www.linuxsir.org/bbs/showthread.php?t=363346 

       http://helloyesyes.iteye.com/blog/1084899 这两个都是 debian 内核编译方法

5.3  http://skpsun.blog.163.com/blog/static/276005520091455245426/

此条目由 navylq 发表在 linux其他 分类目录,并贴了 linux内核 标签。将 固定链接加入收藏夹。

《编译Linux内核》上有 4 条评论

学编译内核,推荐一个网站
http://www.linuxfromscratch.org/


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值