CentOS 7.3 手动编译安装最新版本Linux Kernel

本文演示机器系统版本是CENTOS7.3。 查看系统版本信息。

[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 ~]#

安装编译所需软件。

#逐条运行命令
[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。

[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/

开始配置和编译内核。[截图示例如下图,代码如图下所示] 编译界面

[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

重启电脑并检查是否安装成功。

[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安装最新稳定版内核。

#需要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。

dell@DELL:/usr/src/linux-4.10.10$ sudo apt install libncurses5-dev

开始执行make menuconfig 命令。

dell@DELL:/usr/src/linux-4.10.10$ sudo make menuconfig

执行make命令。编译过程报错。

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。

#解决方法
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:~$

转载于:https://my.oschina.net/u/1011130/blog/870024

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值