複製一份當前系統編譯時的配置,在/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 ....