FEDORA10 编译 linux-2.6.31

来源:互联网 发布:旅游 知乎 成都 编辑:程序博客网 时间:2024/05/08 02:38

转贴 验证通过

Fedora10下编译内核

2009年5月10日LinuxHobby发表评论阅读评论

环境:fedora10,内核包:linux-2.6.29.3.tar.bz2 (F)完整的内核包。

1、将linux-2.6.29.3.tar.bz2复制到/usr/src/kernel
解压索内核包:

tar -jxvf linux-2.6.29.3.tar.bz2

解压后生成一个名为linux-2.6.29.3的目录。

2、将旧内核中config文件复制到linux-2.6.29.3目录下。

cp usr/src/kernel/`uname -r`/.config /usr/src/kernle/linux-2.6.29.3

为什么要这么做?因为.config是旧内核的配置文件,编译新内核并非要完全重来,在模块选择一些参数,基本上是相同的,所以可以沿用前一版本的内核来做小调整即可!

3、重头戏开始了,用什么工具呢?make menuconfig?make xconfig?make gconfig?
当然用make menuconfig了,字符模式,不需要X的支持,make xconfig、make gconfig都需要X支持,make gconfig还需要GDK支持。

执行[root@fedora ~]# make menuconfig

执行后,menuconfig工具读取的就是.config文件,所以现在应该明白刚才那个.config到底是什么了。现在可以通过menuconfig中简单的三个菜单“ “来选择内核模块了,当所有的内核模块都选择完毕后,就保存.config文件。

[root@fedora linux-2.6.29.3]#make clean
这个步骤是清理旧的*.o文件,我这里是编译全新下载的内核,所以等于是多此一句的步骤。

[root@fedora linux-2.6.29.3]#make bzImage
制作核心档案,过程漫长,你现在要做的事情就是冲杯咖啡,看看电影,听听音乐…

[root@fedora linux-2.6.29.3]#make modules
制作内核中选择需要的模块文件。

[root@fedora linux-2.6.29.3]#make modules_install
安装模块,安装的位置当然是/lib/modules中。

[root@fedora linux-2.6.29.3]# make install
sh /usr/src/kernels/linux-2.6.29.3/arch/x86/boot/install.sh 2.6.29.3 arch/x86/boot/bzImage System.map “/boot”
The default plymouth plugin (.so) doesn’t exist
遇到错误了:The default plymouth plugin (.so) doesn’t exist,缺少plymouth plugin的库文件,这好办,立马安装!

[marco.chan@fedora kernels]$ sudo yum install -y plymouth-plugin-solar
中间显示过程省略~

重新执行make install。
[root@fedora linux-2.6.29.3]# make install
sh /usr/src/kernels/linux-2.6.29.3/arch/x86/boot/install.sh 2.6.29.3 arch/x86/boot/bzImage System.map “/boot”
好了,顺利安装。

[root@fedora linux-2.6.29.3]# 查看一下grub.conf文件。[quote]# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,1)
# kernel /boot/vmlinuz-version ro root=/dev/sda2
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,1)/boot/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.29.3) #这就是刚才新编译内核后,产生的启动项目。
root (hd0,1)
kernel /boot/vmlinuz-2.6.29.3 ro root=UUID=0ed5871a-4675-4365-ab8c-375324900450 quiet
initrd /boot/initrd-2.6.29.3.img
title Fedora (2.6.27.21-170.2.56.fc10.i686)
root (hd0,1)
kernel /boot/vmlinuz-2.6.27.21-170.2.56.fc10.i686 ro root=UUID=0ed5871a-4675-4365-ab8c-375324900450 quiet
initrd /boot/initrd-2.6.27.21-170.2.56.fc10.i686.img
title Fedora (2.6.27.5-117.fc10.i686)
root (hd0,1)
kernel /boot/vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=0ed5871a-4675-4365-ab8c-375324900450 quiet
initrd /boot/initrd-2.6.27.5-117.fc10.i686.img
title Other
rootnoverify (hd0,0)
chainloader +1[/quote]
reboot系统,测试能否正常启动。内核编译后,有些软件需要重新编译的,比如说VBOX,NVIDIA等,请在系统重启后重新编译一次即可。