复制一份当前系统编译时的配置,在/usr/src
目录下linux
$ ls /usr/src/ linux-headers-4.10.0-35 linux-headers-4.8.0-36 linux-headers-4.10.0-35-generic linux-headers-4.8.0-36-generic
其中,在 linux-headers-*-generic
目录下存在 .config
文件,复制一份到linux-4.14.14
目录下ubuntu
linux-4.14.14$ cp /usr/src/linux-headers-4.10.0-35-generic/.config .
可能出现的问题bash
$ make menuconfig
*** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** scripts/kconfig/Makefile:202: recipe for target 'scripts/kconfig/dochecklxdialog' failed make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 Makefile:543: recipe for target 'menuconfig' failed make: *** [menuconfig] Error 2
编译出了问题,提示缺乏ncurses
相关的库,安装就好ui
# 提示找不到ncurses-devel包 # sudo apt-get install ncurses-devel sudo apt-get install libncurses5-dev
安装好以后,从新执行,选择[load]–>[OK]–>[Save]–>[OK]–>[EXIT]–>[EXIT]es5
$ make menuconfig
HOSTCC scripts/kconfig/mconf.o HOSTCC scripts/kconfig/lxdialog/checklist.o HOSTCC scripts/kconfig/lxdialog/util.o HOSTCC scripts/kconfig/lxdialog/inputbox.o HOSTCC scripts/kconfig/lxdialog/textbox.o HOSTCC scripts/kconfig/lxdialog/yesno.o HOSTCC scripts/kconfig/lxdialog/menubox.o HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf Kconfig
配置完结果spa
编译启动映像3d
编译的过程比较耗时,-jN部分, N通常设置为内核数量*2,编译速度越快,固然,不要超过本身机器的上限。设置为256,整个内核编译只须要花费大概10min左右。code
make bzImage -j8
可能遇到的2个问题:server
Makefile:942: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
缺乏相应的库,安装便可:sudo apt-get install libelf-dev
blog
fatal error: openssl/opensslv.h: No such file or directory
没有安装openssl的,须要先安装openssl: sudo apt-get install libssl-dev
编译模块
直接执行 make modules -j8
安装内核的过程就快的不少了,这和通常的软件安装包的安装软件 是类似的。
先安装模块
root # make modules_install
再安装内核
root # make install
完成安装以后,会在/boot内生成对应的内核相关文件,重启以后,在启动引导页面,会让咱们选择启动的内核,这时咱们能够选择是当前默认的4.10内核仍是刚刚编译安装的更新的4.14内核。
grub就是管理Ubuntu系统启动的一个程序,咱们编译好的内核要设置为缺省运行项,修改对应的grub,其实也很简单。
查看当前:
$ cat /proc/version
Linux version 4.10.0-35-generic (buildd@lcy01-33) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 $cat /boot/grub/grub.cfg | grep 4.10 ....