zoukankan      html  css  js  c++  java
  • ubuntu系统内核替换

    此处将内核由高版本替换成低版本。替换前的系统为ubuntu 12.04 kernel 3.8.0. 替换后的内核版本为2.6.35.

    首先下载需要替换的内核文件,下载链接:https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.tar.gz

    下载完成后开始进行解压

    $ sudo tar -zxf linux-2.6.35.tar.gz /usr/src

    现在开始进行替换,步骤如下:

    1)安装必要的软件包。在正式替换之前先安装几个必要的软件包:

    $ sudo apt-get install build-essential kernel-package libncurses5-dev libqt3-headers

    各个包的主要作用如下:

      build-essential: 基本的编程库(gcc, make等)

      kernel-package: Debian 系统里生成 kernel-image 的一些配置文件和工具

      libncurses5-dev: make menuconfig要调用的

      libqt3-headers: make xconfig要调用的

    其他的工具在升级过程中可以根据提示安装。

    2)解压。将已经下载的linux-2.6.35.tar.gz拷贝到/usr/src目录下,然后解压到/usr/src/linux-2.6.35目录下。

    3)拷贝原有配置文件。把正在使用中的内核配置文件/usr/src/linux-headers-3.8.0-29-generic/.config 拷到/usr/src/linux-2.6.35目录下

    $ sudo cp /usr/src/linux-headers-3.8.0-29-generic/.config /usr/src/linux-2.6.35

    4)导入配置文件。运行以下命令:

    $ cd /usr/src/linux-2.6.35
    
    $ sudo make menuconfig

    //*************可能出现的问题*************

    问题:提示unable to find the ncurses libraries

    解决方案:sudo apt-get install ncurses-dev

    *************///

    这时,终端会弹出一个配置界面,注意主菜单最后有两项:

    load a kernel configuration...

    save a kernel configuration...

    先选第一项 load ....,意思是,利用当前的内核配置详单来设置将要编译的内核,然后选save这一项保存,最后退出配置界面。

    5)开始编译,依次输入以下命令:

    $ sudo make mrproper   //清除以前曾经编译过的旧文件,如果你是第一次编译,可不执行。
    
    $ sudo make              //编译,此过程需要较长时间。

    //*************可能出现的问题*************

    问题1:gcc: error: elf_i386: no such file or directory

    解决方案:

    在文件:/usr/src/linux-2.6.35/arch/x86/vdso/Makefile中:

    replace "-m elf_x86_64" by "-m64" on the line starting with VDSO_LDFLAGS_vdso.lds

    replace "-m elf_x86" by "-m32" on the line starting with VDSO_LDFLAGS_vdso32.lds

    问题2:error: duplicate member ‘page’

    解决方案:

    打开文件drivers/net/igbvf/igbvf.h,然后将129行的代码注释掉即可。

    struct page *page                  //将此代码删除或注释掉

    **************************//

    $ sudo make install     
    
    $ sudo make modules  //编译模块

    //*************可能出现的问题*************

    问题:modpost: found 96 section mismatch(es).

           ‘make CONFIG_DEBUG_SECTION_MISMATCH=Y’

    解决方案:

           sudo make CONFIG_DEBUG_SECTION_MISMATCH=y

    **************************//

    $ sudo make modules_install  //安装模块

    6)最后创建initrd文件:

    # mkinitramfs -o /boot/initrd.img-2.6.35

    7)更新grub引导列表

    $ sudo update-grub
    
    $ sudo gedit /boot/grub/grub.cfg

    将Code3拷贝至Code1和Code2之间,即将Ubuntu, with Linux 2.6.35启动项拷贝至最前面,这样在重启时系统会自动选择第一个作为默认启动,于是就能进入内核为Linux 2.6.35的系统。

    Code1

    if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi

    Code2

    menuentry 'Ubuntu, with Linux 3.8.0-29-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    
        recordfail
    
        gfxmode $linux_gfx_mode
    
        insmod gzio
    
        insmod part_msdos
    
        insmod ext2
    
        set root='(hd0,msdos1)'
    
        search --no-floppy --fs-uuid --set=root a5208505-6372-4e32-b5f8-8b554b2a0b85
    
        linux    /boot/vmlinuz-3.8.0-29-generic root=UUID=a5208505-6372-4e32-b5f8-8b554b2a0b85 ro   quiet splash $vt_handoff
    
        initrd    /boot/initrd.img-3.8.0-29-generic
    
    }

    Code3:

    menuentry 'Ubuntu, with Linux 2.6.35' --class ubuntu --class gnu-linux --class gnu --class os {
    
        recordfail
    
        gfxmode $linux_gfx_mode
    
        insmod gzio
    
        insmod part_msdos
    
        insmod ext2
    
        set root='(hd0,msdos1)'
    
        search --no-floppy --fs-uuid --set=root a5208505-6372-4e32-b5f8-8b554b2a0b85
    
        linux    /boot/vmlinuz-2.6.35 root=UUID=a5208505-6372-4e32-b5f8-8b554b2a0b85 ro quiet splash $vt_handoff
    
        initrd    /boot/initrd.img-2.6.35
    
    }

    可能出现的问题:

    问题一:在重启后可能会出现如下问题:

    warning: can't open directory /lib/modules/2.6.34/modules.dep, no such files or directory

    解决方案:

    这时,可以先从旧内核中进入系统,然后执行以下命令:

    $ su root         //获得root权限
    
    # cd /boot
    
    # cp initrd.img-2.6.35 initrd-2.6.35.old              //备份原有文件
    
    # depmod –a                                             //检查所有模块
    
    # update-initramfs –k 2.6.35 –c
    
    # cd /tmp
    
    # gzip –dc /boot/initrd.img-2.6.35| cpio –id
    
    # touch lib/modules/2.6.35/modules.dep
    
    # find ./ | cpio –H newc –o > /boot/initrd.img-2.6.35.new
    
    # gzip /boot/initrd.img-2.6.35.new
    
    # cd /boot
    
    # mv initrd.img-2.6.35.new.gz initrd.img-2.6.35

     

    此部分的参考链接:

    http://kpjack.blog.51cto.com/627289/318296/

    内核替换更多介绍:

    http://www.2cto.com/os/201312/265425.html

  • 相关阅读:
    Git Bash 常用指令
    C/C++连接MySQL数据库执行查询
    question from asktom
    ORACLE AWR报告
    查看oracle表索引
    ORACLE数据库关闭与启动
    SYS vs SYSTEM and SYSDBA vs SYSOPER
    【面试】二叉树遍历的非递归实现
    快速排序的非递归实现
    MySQL数据库基础
  • 原文地址:https://www.cnblogs.com/liuwu265/p/4228027.html
Copyright © 2011-2022 走看看