posts - 183,  comments - 10,  trackbacks - 0

Linux 内核编译升级记录

先是装了个 VMware
然后再里面装了个 CentOS

之后就是漫长的内核编译升级

上周周四、周五两天都在忙这个,但是最终没有成功
内核编译一次需要花费一个小时,在虚拟机里面

一开始编译的时候,出现错误。
主要存在两个错误,刚开始不知道为什么,也没有对出现的问题进行解决,只是重新编译,结果当然失败

第一个运行错误是
“insmod: error inserting ‘/lib/dm-region-hash.ko”
Google 了一下,是因为 init 里存在重复行,vi 编辑删除之

第二个错误是:
“Volume group "VolGroup00" not found”
Google 了一下,是因为 .config 文件的配置问题
需要将
General setup --->
enable deprecated sysfs features
勾选了

这两个问题解决后,Linux 内核升级即可完成。
下面说一下具体的步骤:

1.
下载最新版本的 Linux 内核
http://www.kernel.org/
这里是 linux-2.6.37.6.tar.bz2
拷到 /usr/src

2.
加压 *.tar.bz2
root# tar -jvxf linux-2.6.37.6.tar.bz2

3.
进入 linux-2.6.37.6 文件夹
# cd linux-2.6.37.6

# make clean
# make mvproper

4.
配置
make menuconfig
注意,就是这里要勾选
General setup --->
enable deprecated sysfs features
否则会造成
“Volume group "VolGroup00" not found”
错误

5.
编译
# make all

6.
安装
# make modules_install
# make install

7.
设置
# mkinitrd /boot/initrd-2.6.37.6.img 2.6.37.6
# cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.37.6
# cp /usr/src/linux-2.6.37.6/System.map /boot/System.map-2.6.37.6

8. 修改默认启动内核
# cat /etc/grub.conf
# vi /etc/grub.conf
将 default=1 修改为
default=0

9.
删除多余行,这是编译的一个小 bug ,造成出现重复行
会造成
“insmod: error inserting ‘/lib/dm-region-hash.ko”
的错误

# cp /boot/initrd-2.6.37.6.img /tmp/
# cd /tmp/
# mkdir newinitrd
# cd newinitrd
# zcat ../initrd-2.6.37.6.img | cpio -i
# ls
# vi init
删除 init 中存在的重复
echo “Loading dm-region-hash.ko module”
insmod /lib/dm-region-hash.ko
两行
保存

# find . | cpio -c -o > ../initrd
# cd ..
# gzip -9 < initrd > initrd-2.6.37.6.img
# ls
# mv /boot/initrd-2.6.37.6.img /home/
# cp initrd-2.6.37.6.img /boot/
# reboot

进入新内核后,查看新内核的版本
# uname -a
# uname -r

===================================================
下面是我在升级过程中的命令记录 history
  543  tar -jvxf linux-2.6.37.6.tar.bz2
  544  clear
  545  cd linux-2.6.37.6
  546  ls
  547  make clean
  548  make mvproper
  549  clear
  550  make all
  551  make clean
  552  make mrporper
  553  make menuconfig
  554  make menuconfig
  555  \
  556  \
  557  cd /usr/src/linux-2.6.37.6
  558  ls
  559  ls -a
  560  make all
  561  clear
  562  make modules_install
  563  make install
  564  mkinitrd /boot/initrd-2.6.37.6.img 2.6.37.6
  565  rm /boot/initrd-2.6.37.6.img
  566  ls
  567  ls /boot/
  568  mkinitrd /boot/initrd-2.6.37.6.img 2.6.37.6
  569  cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.37.6
  570  cp /usr/src/linux-2.6.37.6/System.map /boot/System.map-2.6.37.6
  571  cat /etc/grub.conf
  572  cp /boot/initrd-2.6.37.6.img /tmp/
  573  cd /tmp/
  574  rm -rf newinitrd/
  575  mkdir newinitrd
  576  cd newinitrd/
  577  zcat ../initrd-2.6.37.6.img | cpio -i
  578  ls
  579  vi init
  580  find . | cpio -c -o > ../initrd
  581  cd ..
  582  gzip -9 < initrd > initrd-2.6.37.6.img
  583  ls
  584  mv /boot/initrd-2.6.37.6.img /home/
  585  cp initrd-2.6.37.6.img /boot/
  586  reboot
  587  uname -r
  588  uname -a
  589  uname -r
  590  history


======================================================

网上查的资料,主要是第一个和第二个
http://www.linuxidc.com/Linux/2010-09/28735.htm
http://blog.csdn.net/douzi24/article/details/5781148
http://hi.baidu.com/mhlovejn/blog/item/7a4a55fe65de7488b801a020.html/
http://blog.csdn.net/cdsnmdl/article/details/3922513
http://www.cublog.cn/u/9483/showart_2524232.html
http://blog.csdn.net/do2jiang/article/details/4965967
http://my.chinaunix.net/space.php?uid=113544&do=blog&id=85646
http://www.cppblog.com/momoxiao/archive/2010/06/26/118758.html

posted on 2011-07-11 11:22 unixfy 阅读(420) 评论(1)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理