本文演示机器系统版本是CENTOS7.3。 查看系统版本信息。linux
[root@localhost ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) Release: 7.3.1611 Codename: Core [root@localhost ~]# [root@localhost ~]# uname -a Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]# [root@localhost ~]# cat /proc/version Linux version 3.10.0-514.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Nov 22 16:42:41 UTC 2016 [root@localhost ~]#
安装编译所需软件。ubuntu
#逐条运行命令 [root@localhost ~]# yum groupinstall "Development Tools" [root@localhost ~]# yum install ncurses-devel [root@localhost ~]# yum install qt-devel
下载最新稳定版本Linux Kernel。本文发表时(2017-03-29)最新稳定内核版本是4.10.6。centos
[root@localhost ~]# wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.6.tar.xz [root@localhost ~]# tar -xf linux-4.10.6.tar.xz -C /usr/src/ [root@localhost ~]# ls /usr/src/ debug kernels linux-4.10.6 [root@localhost ~]# cd /usr/src/linux-4.10.6/
开始配置和编译内核。[截图示例以下图,代码如图下所示] dom
[root@localhost linux-4.10.6]# make menuconfig scripts/kconfig/mconf Kconfig # # using defaults found in /boot/config-3.10.0-514.el7.x86_64 # /boot/config-3.10.0-514.el7.x86_64:621:warning: symbol value 'm' invalid for CPU_FREQ_STAT /boot/config-3.10.0-514.el7.x86_64:861:warning: symbol value 'm' invalid for NF_CT_PROTO_DCCP /boot/config-3.10.0-514.el7.x86_64:863:warning: symbol value 'm' invalid for NF_CT_PROTO_SCTP /boot/config-3.10.0-514.el7.x86_64:864:warning: symbol value 'm' invalid for NF_CT_PROTO_UDPLITE /boot/config-3.10.0-514.el7.x86_64:882:warning: symbol value 'm' invalid for NF_NAT_PROTO_DCCP /boot/config-3.10.0-514.el7.x86_64:883:warning: symbol value 'm' invalid for NF_NAT_PROTO_UDPLITE /boot/config-3.10.0-514.el7.x86_64:884:warning: symbol value 'm' invalid for NF_NAT_PROTO_SCTP configuration written to .config *** End of the configuration. *** Execute 'make' to start the build or try 'make help'. #编译用时与机器配置,选择选项等有关,大约须要十几分钟以上 [root@localhost linux-4.10.6]# make [root@localhost linux-4.10.6]# make modules_install [root@localhost linux-4.10.6]# make install [root@localhost linux-4.10.6]# make clean #更新内核启动参数 [root@localhost linux-4.10.6]# grub2-set-default 0
重启电脑并检查是否安装成功。ui
[root@localhost ~]# uname -a Linux localhost.localdomain 4.10.6 #1 SMP Wed Mar 29 13:47:22 CST 2017 x86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) Release: 7.3.1611 Codename: Core [root@localhost ~]#
补充Ubuntu安装最新稳定版内核。es5
#须要root权限 dell@DELL:/usr/src/linux-4.10.10$ sudo make menuconfig HOSTCC scripts/kconfig/mconf.o In file included from scripts/kconfig/mconf.c:23:0: scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: 没有那个文件或目录 compilation terminated. scripts/Makefile.host:124: recipe for target 'scripts/kconfig/mconf.o' failed make[1]: *** [scripts/kconfig/mconf.o] Error 1 Makefile:546: recipe for target 'menuconfig' failed make: *** [menuconfig] Error 2 dell@DELL:/usr/src/linux-4.10.10$ dell@DELL:/usr/src/linux-4.10.10$ sudo
该错误是由于make menuconfig须要安装libncurses5-dev。debug
dell@DELL:/usr/src/linux-4.10.10$ sudo apt install libncurses5-dev
开始执行make menuconfig 命令。code
dell@DELL:/usr/src/linux-4.10.10$ sudo make menuconfig
执行make命令。编译过程报错。cdn
scripts/sign-file.c:25:30: fatal error: openssl/opensslv.h: 没有那个文件或目录 compilation terminated. scripts/Makefile.host:107: recipe for target 'scripts/sign-file' failed make[1]: *** [scripts/sign-file] Error 1 Makefile:560: recipe for target 'scripts' failed make: *** [scripts] Error 2 dell@DELL:/usr/src/linux-4.10.10$
解决该方法是安装libssl-dev。ip
#解决方法 dell@DELL:/usr/src/linux-4.10.10$ sudo apt install libssl-dev
其余状况和CentOS安装相似,本文再也不加以详细讲解。
须要补充一点。
dell@DELL:/usr/src/linux-4.10.10$ sudo grub-set-default 0 dell@DELL:/usr/src/linux-4.10.10$ cat /proc/version Linux version 4.4.0-72-generic (buildd@lcy01-17) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 dell@DELL:/usr/src/linux-4.10.10$ sudo reboot
安装完成后检查版本。
dell@DELL:~$ uname -a Linux DELL 4.10.10 #1 SMP Thu Apr 13 15:54:58 CST 2017 x86_64 x86_64 x86_64 GNU/Linux dell@DELL:~$ cat /proc/version Linux version 4.10.10 (root@DELL) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #1 SMP Thu Apr 13 15:54:58 CST 2017 dell@DELL:~$