升级内核版本(自己编译源码)

  1. 从 linux 官网 https://www.kernel.org/ 下载内核源码
  2. 解压

    tar -xvf linux-4.16.8.tar.xz
    cd linux-4.16.8/

  3. 编译(出现问题)

    make

    出现

    /bin/sh: 1: bison: not found
    scripts/Makefile.lib:217: recipe for target 'scripts/kconfig/zconf.tab.c' failed
    make[2]: *** [scripts/kconfig/zconf.tab.c] Error 127
    Makefile:514: recipe for target 'silentoldconfig' failed

    解决方法

    sudo apt-get install bison

    继续 make 又出现

    /bin/sh: 1: flex: not found
    scripts/Makefile.lib:202: recipe for target 'scripts/kconfig/zconf.lex.c' failed
    make[2]: *** [scripts/kconfig/zconf.lex.c] Error 127
    Makefile:514: recipe for target 'silentoldconfig' failed

    解决

    sudo apt-get install flex

    大概可以看出来,编译时缺少什么就安装什么

  4. 配置

    make menuconfig

    使用默认配置,save 后 exit

  5. 修复配置后编译 (4线程)

    make -j 4

  6. 安装内核模块

    sudo make modules_install

  7. 安装内核

    sudo make install

关于VirtualBox 对 header 的依赖
我在升级完内核版本后,把旧的linux启动项给删除了,header 应该也被我删除,然后启动vbox 失败,想起vbox需要有linux-header才能运行,然后安装header

sudo apt-get install linux-headers-4.16.0-1-amd64

安装完 header 后可以发现其存在 /usr/src 中,当然 vboxhost-5.2.1 也在里面,后面再启动vbox就没有问题了