免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 965 | 回复: 0
打印 上一主题 下一主题

内核编译心得 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-08 23:00 |只看该作者 |倒序浏览
编译内核前先到kernel.org把内核下来,
tar -xvjf linux-***.tar.gz
mv -a linux-*** /usr/src/
cd linux-***
make rmproper
make menuconfig
编译完以后
因为 2.6以后的内核解决了依赖关系
所以 make dep就不必了
make
make modules-install

六、安装内核及配置grub或lilo ;

1、复制bzImage等相关文件,并创建initrd文件;

[root@localhost linux-2.6.12.3]# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.12.3
[root@localhost linux-2.6.12.3]# cp System.map /boot/System.map-2.6.12.3
[root@localhost linux-2.6.12.3]# cd /boot
[root@localhost linux-2.6.12.3]# /sbin/mkinitrd initrd-2.6.12.3.img 2.6.12.3
我们把 编译出来的bzImage,拷入到/boot目录,拷贝成 vmlinuz-2.6.12.3;
并且用 mkinitrd 来创建imitrd-xxx.img 文件,其中xxx为内核的版本号,是通过 查看 /lib/modules来版本来对应的,我们是编译出来的是 2.6.12.3,所以就运行上面的命令创建,创建的出来的是initrd-2.6.12.3.img ;不创建这个文件,有时是启动不起来的,比如提示VFS错误等;

这样就编译好了,并把模块也安装在了 /lib/modules目录中了,请看:
[root@localhost linux-2.6.12.3]# ls /lib/modules/
2.6.11-1.1369_FC4 2.6.12.3

六、安装内核及配置grub或lilo ;


1、复制bzImage等相关文件,并创建initrd文件;

[root@localhost linux-2.6.12.3]# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.12.3
[root@localhost linux-2.6.12.3]# cp System.map /boot/System.map-2.6.12.3
[root@localhost linux-2.6.12.3]# cd /boot
[root@localhost linux-2.6.12.3]# /sbin/mkinitrd initrd-2.6.12.3.img 2.6.12.3
我们把 编译出来的bzImage,拷入到/boot目录,拷贝成 vmlinuz-2.6.12.3;
并且用 mkinitrd 来创建imitrd-xxx.img 文件,其中xxx为内核的版本号,是通过 查看 /lib/modules来版本来对应的,我们是编译出来的是 2.6.12.3,所以就运行上面的命令创建,创建的出来的是initrd-2.6.12.3.img ;不创建这个文件,有时是启动不起来的,比如提示VFS错误等;

2、查看系统引导管理器grub或者lilo的配置文件。

如果想要让新内核能让系统引导管理器grub和lilo的菜单上能看得到,必须改 grub.conf或者lilo.conf,但我们必须保留老内核的在grub和lilo的启动菜单,毕竟我们编内核不能百分百的成功,对不对??安全第一吧;
我只说grub的,我没有lilo,也不会用。所以咱们还是GRUB吧,FC 4 系统引导管理器是 GRUB,所以我们谈谈GRUB的设置;
查看 /etc/grub.conf;
比如我的grub.conf的内容是这样的;
# 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,7)
# kernel /boot/vmlinuz-version ro root=/dev/hda8
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
#splashimage=(hd0,7)/boot/grub/splash.xpm.gz
#hiddenmenu
title Fedora Core (2.6.11-1.1369_FC4)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.11-1.1369_FC4.img
title WinXP
        rootnoverify (hd0,0)
        chainloader +1
我们要把老内核的启动保留下来,以防不测,我们只加入新的内核的启动;所以我加上这样一段;
title Fedora Core (2.6.12.3)
root (hd0,7)
kernel /boot/vmlinuz-2.6.12.3 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.12.3.img
咱们再来看一下改过后的配置文件;
# 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,7)
# kernel /boot/vmlinuz-version ro root=/dev/hda8
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
#splashimage=(hd0,7)/boot/grub/splash.xpm.gz
#hiddenmenu
title Fedora Core (2.6.12.3)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.12.3 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.12.3.img
title Fedora Core (2.6.11-1.1369_FC4)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.11-1.1369_FC4.img
title WinXP
        rootnoverify (hd0,0)
        chainloader +1
然后重新启动机器,如果出现VFS错误,可能就是我写重要的那个地方出了错误;
注意:如果重新启用内核后,原来安装的显示卡驱动,比如 NVIDIA和ATI的驱动还要重新安装;



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/12257/showart_82750.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP