Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2307886
  • 博文数量: 395
  • 博客积分: 10994
  • 博客等级: 上将
  • 技术积分: 5586
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-17 19:49
文章存档

2014年(1)

2013年(10)

2012年(74)

2011年(303)

2010年(7)

分类: LINUX

2011-06-14 10:34:28


 linux 内核升级方法

  1. 前沿:你是不是为你的x86下linux代码的内核版本和嵌入式编译的时候不一致而发愁,下面的过程主要是内核的编译和升级的步骤。
  2.   
  3. 注:下面只贴代码,注意哪些带颜色的就是步骤中很重要的部分(下面代码在redhat中实验成功,在centos有些不同,不过后来也成功了(下面介绍的有))
  4.   
  5. 1.redhat中的步骤

  6. [root@localhost guoqian]# ls

  7. linux-2.6.29 linux-2.6.29.tar.bz2

  8. [root@localhost guoqian]# cd linux-2.6.29

  1. [root@localhost linux-2.6.29]# cp /boot/config-2.6.18-53.el5 ./.config

  2. [root@localhost linux-2.6.29]# ls -a

  3. . COPYING firmware ipc MAINTAINERS REPORTING-BUGS usr

  4. .. CREDITS fs Kbuild Makefile samples virt

  5. arch crypto .gitignore kernel mm scripts

  6. block Documentation include lib net security

  7. .config drivers init .mailmap README sound

  8. [root@localhost linux-2.6.29]# make menuconfig

  9.   HOSTCC scripts/basic/fixdep

  10.   HOSTCC scripts/basic/docproc


  11. [root@localhost linux-2.6.29]# make bzImage

  12. ……..


  13.   OBJCOPY arch/x86/boot/setup.bin

  14.   OBJCOPY arch/x86/boot/vmlinux.bin

  15.   HOSTCC arch/x86/boot/tools/build

  16.   BUILD arch/x86/boot/bzImage

  17. Kernel: arch/x86/boot/bzImage is ready (#1)

  18. [root@localhost linux-2.6.29]# make modules

  19. ....


  20. root@localhost linux-2.6.29]# make modules_install


  21. [root@localhost linux-2.6.29]# ls /lib/modules/

  22. 2.6.18-53.el5 2.6.29 (这个2.6.29出来了,这个是为下面做准备)

  23. [root@localhost linux-2.6.29]# cd ..

  24. [root@localhost guoqian]# ls

  25. 4-1-2 linux-2.6.29 linux-2.6.29.tar.bz2

  26. [root@localhost guoqian]# mkinitrd initrd-2.6.29 2.6.29

  27. [root@localhost guoqian]# ls

  28. 4-1-2 initrd-2.6.29 linux-2.6.29 linux-2.6.29.tar.bz2


  29. [root@localhost guoqian]# cp initrd-2.6.29 /boot/

  30. [root@localhost guoqian]# ls /boot

  31. config-2.6.18-53.el5 initrd-2.6.29 System.map-2.6.18-53.el5

  32. grub lost+found vmlinuz-2.6.18-53.el5

  33. initrd-2.6.18-53.el5.img symvers-2.6.18-53.el5.gz

  34.  [root@localhost guoqian]# cp ./linux-2.6.29/arch/x86/boot/bzImage /boot/vmlinuz-2.6.29

  35. (注:上面这个名字很重要,后面的那个2.6.29一定要和/lib/modules目录下的有才行)

  36. [root@localhost guoqian]# ls /boot

  37. config-2.6.18-53.el5 initrd-2.6.29 System.map-2.6.18-53.el5

  38. grub lost+found vmlinuz-2.6.18-53.el5

  39. initrd-2.6.18-53.el5.img symvers-2.6.18-53.el5.gz vmlinuz-2.6.29

  40.  

  41. [root@localhost guoqian]# vi /etc/grub.conf

  42. # grub.conf generated by anaconda

  43. #

  44. # Note that you do not have to rerun grub after making changes to this file

  45. # NOTICE: You have a /boot partition. This means that

  46. # all kernel and initrd paths are relative to /boot/, eg.

  47. # root (hd0,1)

  48. # kernel /vmlinuz-version ro root=/dev/sda1

  49. # initrd /initrd-version.img

  50. #boot=/dev/sda

  51. default=0

  52. timeout=7

  53. splashimage=(hd0,1)/grub/splash.xpm.gz

  54. hiddenmenu

  55. title Red Hat Enterprise Linux Server (2.6.18-53.el5)

  56.         root (hd0,1)

  57.         kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet

  58.         initrd /initrd-2.6.18-53.el5.img


  59. title My-Linux(2.6.29)

  60.         root (hd0,1)

  61.         kernel /vmlinuz-2.6.29 ro root=LABEL=/ rhgb quiet

  62.         initrd /initrd-2.6.29

  63.  

  64. 1.centos中的步骤

  65. 上面的是redhat中的设置,下面介绍一下centos中的设置:基本上所有的都一样,就是最后的哪一个配置文件有些不同,下面贴出来centos中的/etc/grub.conf中的内容:

  66. # grub.conf generated by anaconda

  67. #

  68. # Note that you do not have to rerun grub after making changes to this file

  69. # NOTICE: You do not have a /boot partition. This means that

  70. # all kernel and initrd paths are relative to /, eg.

  71. # root (hd0,0)

  72. # kernel /boot/vmlinuz-version ro root=/dev/sda1

  73. # initrd /boot/initrd-version.img

  74. #boot=/dev/sda

  75. default=0

  76.  

  77. timeout=5

  78. splashimage=(hd0,0)/boot/grub/splash.xpm.gz

  79. hiddenmenu

  80. title CentOS (2.6.18-194.32.1.el5)

  81.         root (hd0,0)

  82.         kernel /boot/vmlinuz-2.6.18-194.32.1.el5 ro root=LABEL=/ apm=on apm=powe-off rhgb quiet

  83.         initrd /boot/initrd-2.6.18-194.32.1.el5.img

  84. title CentOS (2.6.18-92.el5)

  85.         root (hd0,0)

  86.         kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ apm=on apm=powe-off rhgb quiet

  87.         initrd /boot/initrd-2.6.18-92.el5.img

  88.  

  89. #下面的是我添加的

  90. title my_linux(2.6.29)

  91.         root(hd0,0)

  92.         kernel /boot/vmlinuz-2.6.29 ro root=LABEL=/ apm=on apm=powe-off rhgb quiet

  93.         initrd /boot/initrd-2.6.29

  94.  

  95. /*看到了么,centos中就是比redhat中多了一个/boot(后来证明,这个/boot也不一定,你要看原来的设置,直接复制粘贴,修改,因为我发现centos有时候会变的)

  96. 还有多了kernel中后面的那些内容。不过我还是有点郁闷,centos不是说是redhat的克隆版么?怎么会这个地方不一样?怎么解释。。。呵呵。。*/

阅读(2267) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~