背景:
当前是CentOS 5.1.3,其内核是linux-2.6.18,版本高于即将编译的内核版本linux-2.4.20,所以要特别注意。
第一:从www.linuxhq.com,www.kernel.org或者ftp.kernel.ort下载linux-2.4.20.tar.bz2包,拷贝#cp linux-2.4.20.tar.bz2 /usr/src/。解压#tar -jxvf linux-2.4.20.tar.bz2。得到linux-2.4.20目录。
第二:清除从前编译内核时残留的.o 文件和不必要的关联 :
cd /usr/src/linux
make mrproper
第三:配置内核,修改相关参数,请参考其他资料(http://soft.yesky.com/os/lin/370/2018870_1.shtml)
基于文本的最为传统的配置界面: #make config
图形界面下: #make xconfig
字符界面下: #make menuconfig
只想在原来内核配置的基础上修改一些小地方: #make oldconfig
在内核配置菜单中正确设置各个内核选项,保存退出。
-----------------------------------------------------------------------------------------
》如果选择图形界面,这一步中可能会遇到点麻烦:
报错:
make: wish:命令未找到
make: *** [xconfig] 错误 127
经查,是没有安装tcl,tk两个东东。下载:http://www.tcl.tk/software/tcltk/downloadnow85.html 。得到tcl8.5.6-src.tar.gz和tk8.5.6-src.tar.gz。解压:#tar -xzvf tcl8.5.6-src.tar.gz以及#tar -xzvf tk8.5.6-src.tar.gz得到tcl8.5a5,tk8.5a5。
# cd /usr/tcl8.5a5/unix
# ./configure --prefix=/usr/
.
#make install
.
//对于tk的做法完全类似...
.
//因为默认生成的的文件名是wish8.5,所以要做一个链接:
# ln /usr/bin/wish8.5 /usr/bin/wish
------------------------以上感谢www.eeworld.com的pajoke-------------------
》再#make xconfig 还是出错:
Application initialization failed: no display name and no $DISPLAY environment variable Error in startup script: invalid command name "button"
while executing
"button .ref"
(file "scripts/kconfig.tk" line 51)
make: *** [xconfig] 错误 1
无数次的尝试,都是这样,失败!google上找去找来,也没有人说明白的!最后无奈了,想试试看重新编译当版本的内核,结果报错:
qconf: cannot connect to X server
make[1]: *** [xconfig] 错误 1
make: *** [xconfig] 错误 2
发现了,这与Xwindows有关,启动#xhost +,出错:xhost: unable to open display "",最后明白了,原来,我用fterm远程登录要编译内核的主机,这需要#xhost + ip(如192.168.0.126),结果还是不行,TNND,我直接到那台主机上编译#make xconfig,OK!
-------以上感谢http://space.itpub.net/12778571的mengzhaoliang-------
第四:可参考http://blog.csdn.net/weide001/archive/2009/03/05/3959878.aspx的步骤六即可。
#make dep
#make clean
#make bzImage
#cp /usr/src/linux2.4.20/arch/i386/boot/bzImage /boot/vmlinuz-2.4.20_new
#make modules
#make modules_install
#make install
#reboot
。。。
引导进入新内核系统 Red Hat Linux (2.4.20custom)
第五:打完收工...