免费注册 查看新帖 |

Chinaunix

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

centos 5.3 内核升级到2.6.32.6 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-03 17:19 |只看该作者 |倒序浏览
linux 内核编译
一、准备阶段
1、kernel-2.6.32.6:
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.6.tar.bz2
2、iptables-1.4.6:
wget http://www.netfilter.org/projects/iptables/files/iptables-1.4.6.tar.bz2
wget http://www.netfilter.org/projects/iptables/files/patch-iptables-1.4.5-1.4.6.bz2
3、netfilter-layer7:
wget http://downloads.sourceforge.net/project/l7-filter/l7-filter%20kernel%20version/2.22/netfilter-layer7-v2.22.tar.gz?use_mirror=cdnetworks-kr-2
帮助文件:http://l7-filter.sf.net/HOWTO-kernel
非常不错的帮助文档,如果安装前详细阅读,安装过程中能减少很多错误,因为没有事先看,害得我重编译了好多次;
4、l7-protocols-2009-05-28:
wget http://downloads.sourceforge.net/project/l7-filter/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz?use_mirror=cdnetworks-kr-1
5、将上述文件下载至/usr/src 下,解压:
tar -jxvf iptables-1.4.6.tar.bz2  && tar -zxvf l7-protocols-2009-05-28.tar.gz && tar -zxvf netfilter-layer7-v2.22.tar.gz && \
tar -jxvf linux-2.6.32.6.tar.bz2 && bunzip2 patch-iptables-1.4.5-1.4.6.bz2
二、开始编译
1、切换到 l7-protocols-2009-05-28 目录,执行 make install
#cd l7-protocols-2009-05-28
#cat Makefile
all:
        @echo Nothing to compile, just run \'make install\'
        @echo \(This simply copies this directory into $(PREFIX)/etc/l7-protocols \)
install:
        mkdir -p $(PREFIX)/etc/l7-protocols
        cp -R * $(PREFIX)/etc/l7-protocols
#make install
2、切换至 linux-2.6.32.6 目录,编译 kernel
#cd linux-2.6.32.6
#利用发行版本提供的.config 来配置, 这样方便点;
#cp /boot/config-2.6.18-128.el5  .config
#patch -p1 Networking support-->Networking options-->Network packet filtering framework (Netfilter)
勾选需要的模块,然后退出,保存至.config。
备注:
     内核配置有两种方法,一种是直接置入内核 * ;另一种是编成模块 M ;两种方法各有优点;直接编入内核的,
比如设备的启动,不再需要加载模块的这一过程了;而编译成模块,则需要加载设备的内核支持的模块;但直接把
所有的东西都编入内核也不是可行的,内核体积会变大,系统负载也会过重。我们编内核时最好把极为重要的编入
内核;其它的如果您不明白的,最好用默认。
如果不勾选“Netfilter connection tracking support”   ,那么“”layer7” match support”将不会在这里显示出来,
务必将“Netfilter connection tracking support”打上对勾。
# make && make modules_install && make install
# vi /boot/grub/grub.conf       #以新内核启动系统,重启系统;
###############################################################################
备注:
make install 时报警告:
WARNING: No module dm-mem-cache found for kernel 2.6.32.6, continuing anyway
WARNING: No module dm-message found for kernel 2.6.32.6, continuing anyway
WARNING: No module dm-raid45 found for kernel 2.6.32.6, continuing anyway
解决办法:http://www.linuxidc.com/Linux/2009-06/20448.htm
一、是当使用mkinitrd时,使用”–without-dmraid”这个参数。然后再运行mkinitrd命令。
# mkinitrd /boot/initrd-2.6.32.6.img 2.6.32.6 --without-dmraid
执行完mkinitrd后,就要在启动菜单中增加编译好的内核信息,以便启动时可以选择内核版本。
# cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.6
# cp System.map /boot/System.map-2.6.32.6
打开/etc/grub.conf文件,增加以下内容到文件结尾。
title CentOS (2.6.32.6)
        root (hd0,0)
        kernel /vmlinuz-2.6.32.6 ro root=LABEL=/
        initrd /initrd-2.6.32.6.img
保存,重启,进行grub的启动菜单中,选择”CentOS(2.6.32.6)”,即可使用编译好的内核
二、是在使用mkinitrd之前,先创建一个noraid文件。创建方法如下:
# echo "DMRAID=no" > /etc/sysconfig/mkinitrd/noraid
# chmod 755 /etc/sysconfig/mkinitrd/noraid
然后再运行make install命令。
三、新内核启动系统是报错:
could not find filesystem '/dev/root'
终于找到了http://patchwork.kernel.org/patch/37444/ 这个网页,从里面找到了Solution,问题出在了CONFIG_SYSFS_DEPRECATED_V2这个选项上了.
解决办法如下编辑内核源码包里面的.config文件.
CONFIG_SYSFS_DEPRECATED_V2=y #默认该选项为not set,被注释掉的.
然后再编译一遍内核就都OK了.
###############################################################################
3、切换至 iptables-1.4.6 目录,编译 iptables
通过rpm -qa|grep iptables 查找系统已经安装的iptables rpm包
通过rpm -e 删除iptables rpm包
layer7 官方帮助:
     http://l7-filter.sf.net/HOWTO-kernel
  iptables 1.4.1.1 and newer
  Copy libxt_layer7.c and libxt_layer7.man (from the subdirectory of the "Layer 7 patches"
  package that the README points you to) to the extensions/ directory of your iptables source.
  Then:
     "./configure --with-ksource=/path/to/patched/kernel_source" (use the full path)
     "make"
     (as root) "make install"
#cd iptables-1.4.6
#cp /usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/*  /usr/src/iptables-1.4.6/extensions/
#./configure --with-kernel=/usr/src/linux-2.6.32.6 --with-ksource=/usr/src/linux-2.6.32.6  --enable-static --enable-shared && make && make install && reboot
备注:
如果不将/usr/src/netfilter-layer7-v2.22/iptables-1.4.1.1-for-kernel-2.6.20forward/下的 libxt_layer7.c、       libxt_layer7.man
拷贝至/usr/src/iptables-1.4.32.6/extensions/下,编译时将出现大量错误提示,编译失败,另外执行 iptables 规则时将出
现以下错误提示:
iptables v1.4.6: Couldn't load match `layer7':/usr/local/libexec/xtables/libipt_layer7.so: cannot open shared object file:
No such file or directory
Try `iptables -h' or 'iptables --help' for more information.
###############################################################################
备注:
报kernel: can't load conntrack support for proto=2错误:由于/lib/kernel/net/ipv4/netfilter/下面缺少一个缺少 nf_conntrack_ipv4.ko 造成的
iptables 编译安装前,删除系统里面RPM的iptables :
find / -name iptables|xargs rm -rf

grep CONNTRACK /boot/config-$(uname -r)
# CONFIG_NF_CONNTRACK_IPV4 is not set
编译内核时 make menuconfig 后,需要修改.config文件:
CONFIG_SYSFS_DEPRECATED_V2=y
CONFIG_NF_CONNTRACK_IPV4=y
###############################################################################


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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP