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

前端之家收集整理的这篇文章主要介绍了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/
#编译时可能会遇到错误 make menuconfig少一个字母n
[root@localhost linux-4.10.6]# make menucofig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] 错误 1
make[1]: *** [silentoldconfig] 错误 2
make: *** 没有规则可以创建目标“menucofig”。 停止。
#本机是KDE桌面环境

开始配置和编译内核。

[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://www.f2er.com/centos/378181.html

猜你在找的CentOS相关文章