centos下编译linux2.6.33.6

1、先到kerner.org下载源代码

2、将源代码解压到/usr/src下,会建立一个文件夹linux-2.6.33.6
cd /usr/src/linux-2.6.33.6

3、配置
make menuconfig
中间要安装库yum install ncurses ncurses-devel
注意加上kgdb的配置:在kernel hacking菜单下

这里还要修改配置文件.config,把以下选项加上
CONFIG_SYSFS_DEPRECATED_V2=y

不然报无法挂载mounting /dev/root文件系统错误

4、编译内核
make && make modules_install && make install

5.编译后还要修改img文件

cp /boot/initrd-2.6.33.6.img /tmp

[root@bogon ~]# cd /tmp/



[root@bogon tmp]# mkdir newinitrd

[root@bogon tmp]# cd newinitrd/

[root@bogon newinitrd]# zcat ../initrd-2.6.33.6.img |cpio -i

编辑init,删掉其中重复的四行中的两行

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

重新打包initrd

[root@bogon newinitrd]# find .|cpio -c -o > ../initrd

[root@bogon newinitrd]# cd ..

[root@bogon tmp]# gzip -9 < initrd > initrd.img


最后将新的 initrd.img文件拷贝到/boot下,且重命名就OK了


附我的/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/sda2
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=15
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.33.6)
        root (hd0,0)
        kernel /vmlinuz-2.6.33.6 ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.33.6.img
title CentOS (2.6.18-238.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-238.el5 ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.18-238.el5.img

posted @ 2015-06-20 23:18  szphper  阅读(568)  评论(0)    收藏  举报