centos 5.5 x86_64 初始安装的使用的内核是2.6.18 版本

 

 

 

root 登录(默认为 /root);

#wget  http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.9.tar.bz2

#tar -xjvf linux-2.6.35.9.tar.bz2 

#mv linux-2.6.35.9  /usr/src/kernels

为了方便编译配置 将 boot 目录下的 配置文件  复制到 /usr/src/kernels/linux-2.6.35.9

#cp  /boot/config-2.6.18-194.17.4.el5    /usr/src/kernels/linux-2.6.35.9/.config


#make menuconfig 

 

*** Unable to find the ncurses libraries or the

 *** required header files.

 *** 'make menuconfig' requires the ncurses libraries.

 *** 

 *** Install ncurses (ncurses-devel) and try again.

 *** 

make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1

make: *** [menuconfig] Error 2

  

   这里我遇到以上的问题,网上讲是由于apt-get install libncurses* 没有安装导致的,但是我apt没有执行到,没有深入找问题,接着我查到了

执行

yum install ncurses-devel  

把问题解决了。  在之前我还

yum groupinstall "Development Tools"

yum install gcc 安装了gcc,网上也有朋友讲是gcc的版本问题。

 

接着可以继续安装

 

#make menuconfig    选择 Load an Alternate Configuration    回车确认载入

根据需要再选择编译选项;

#这里很多选择,我果断不明白把它跳过了

 

#make    (时间是非常的久,我还在等待中,和网上讲的一样,最后等了1个小时)

如果没有错误,执行模块编译安装

 

 #make modules_install

  
编译内核安装

#make install

      sh /usr/src/kernels/linux-2.6.35.9/arch/x86/boot/install.sh 2.6.35.9 arch/x86/boot/bzImage \
                System.map "/boot"
看到如上提示表示编译成功,

 

 

如果没有看到错误,可以修改启动项 让 centos 启动时加载 新内核, (如有编译错误请勿修改启动配置,否则启动失败)

vi /boot/grub/grub.conf

default=0  (修改为0 即可)

 

千万要确认了可以正常启动,再把可能不需要的内核给删除。

我按照网上的安装安装到这里,后面的 这样写的:

 

 

 

 在线虚拟机上 升级 centos 5.5 到 2.6.3X  启动时会提示如下错误:

mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!

解决方法:(我看这步要提前完成,要不会杯具)


 

 

执行完make menuconfig后,修改/usr/src/kernels/linux-2.6.35.9/.config

将#CONFIG_SYSFS_DEPRECATED_V2 is not set
默认被注释掉的,将其改为y。即修改为
CONFIG_SYSFS_DEPRECATED_V2=y

 

最后结果: 还是没登陆上去  哈~~杯具 ,,在看~

 

 

 

 

另外 centos 作为服务器操作系统,  在编译配置选项中,  我想 声卡之类的 东西是不需要编译进去的, 这样可以加快编译速度,减少内核大小 (声卡我也编译了,估计浪费了不少时间)

 

 

 

 解压修改内核:

cp /boot/initrd-2.6.35.1.img /tmp/
cd /tmp/
mkdir newinitrd
cd newinitrd/
zcat ../initrd-2.6.35.1.img |cpio -i
rm -fr /tmp/initrd-2.6.35.1.img

vim init

找到这2段一样的,去掉其中1段重复的:

echo “Loading dm-region-hash.ko module”
insmod /lib/dm-region-hash.ko
echo “Loading dm-region-hash.ko module”
insmod /lib/dm-region-hash.ko

5、从新打包新内核:

find .|cpio -c -o > ../initrd
cd ../
gzip -9 < initrd > initrd-2.6.35.1.img
rm -fr /boot/initrd-2.6.35.1.img
cp initrd-2.6.35.1.img /boot

 

 将#CONFIG_SYSFS_DEPRECATED_V2 is not set

默认被注释掉的,将其改为y。即修改为
CONFIG_SYSFS_DEPRECATED_V2=y

我按照这里的,

执行完make menuconfig后就改了 重新来一次,就可以了,这次等待时间短了,这个写文档果断要顺序,给折腾我一会了,回头整理文档。