Linux-2.6.21.3编译过程笔记
发布时间:2007-05-26 00:29:43来源:红联作者:Quickgram
机器:dell 1950
系统:RedHat RHEL5 (2.6.18-8.el5)
1、从www.kernel.org下载linux-2.6.21.3.tar.bz2
#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.3.tar.bz2
2、解压到/usr/src
#tar jxvf linux-2.6.21.3.tar.bz2 -C /usr/src/linux-2.6.21.3;cd /usr/src/
3、创建一个linux-2.6.21.3的软连接 linux
#ln -s /usr/src/linux-2.6.21.3 /usr/src/linux;cd /usr/src/linux
4、优化,修改内核源代码
1).修改/usr/src/linux/include/linux/posix_types.h
设置fd_set支持的最大数量
#define __FD_SETSIZE 1024 ---> 65536
2).修改/usr/src/linux/include/linux/fs.h
设置最大打开文件数量(TCP连接数量)
#define INR_OPEN 1024 ---> 65536
#define NR_FILE 8192 ---> 65536
#define NR_RESERVED_FILES 10 ---> 128
3).修改/usr/src/linux/include/net/tcp.h
设置TIMEOUT的时间为1秒
#define TCP_TIMEWAIT_LEN (60*HZ) 60 ---> 1*HZ
设置在backlog队列里的半连接的重试次数,每次都会花相应的时间,本质上 也是减少重试时间
#define TCP_SYNACK_RETRIES 5 ---> 3
5、从原始的RHEL5的/usr/src/kernels/2.6.18-8.el5-i686/目录下cp一份.config文件到/usr/src/linux下
#cp /usr/src/kernel/2.6.18-8.e15-i686/.config /usr/src/linux
6、切换到/usr/src/linux开始编译新的内核
#cd /usr/src/linux;make menuconfig
不用任何改动,直接保存退出。
注:从2.6.19以后的内核中新增了ext4的文件系统,可在file systems中选择ext4文件系统模块
7、编译安装
步骤:make -jn(n代表同时编译的进程,可以加快编译速度,n由你的配置决定,我的配置用15-25)
make modules_install install
注:第一次编译安装新的内核可使用 make modules_install install,如果是更新或升级内核只需使用make modules_install,使用 make install系统在加载新的内核时会panic!
8、修改/etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda3
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.21.3)
root (hd0,0)
kernel /vmlinuz-2.6.21.3 ro root=LABEL=/
initrd /initrd-2.6.21.3.img
title Red Hat Enterprise Linux Server (2.6.18-8.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/
initrd /initrd-2.6.18-8.el5.img
9、reboot
10、启动后
#uname -r
2.6.21.3
内核编译安装成功。