rpm升级
1.载入内核公钥
[root@localhost ~]
2.安装内核 ELRepo
[root@localhost ~]
3.载入elrepo-kernel元数据
[root@localhost ~]
4.查看可用的rpm包
[root@localhost ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo-kernel: mirrors.neusoft.edu.cn
Installed Packages
kernel.x86_64 3.10.0-957.el7 @anaconda
kernel-tools.x86_64 3.10.0-957.el7 @anaconda
kernel-tools-libs.x86_64 3.10.0-957.el7 @anaconda
Available Packages
kernel-lt.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.235-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.8.7-1.el7.elrepo elrepo-kernel
5.安装最新版本的kernel
[root@localhost ~]
6.删除旧版本工具包
[root@localhost ~]
7.安装新版本工具包
[root@localhost ~]
编译升级
升级前
[root@localhost ~]
3.10.0-957.el7.x86_64
[root@localhost ~]
CentOS Linux release 7.6.1810 (Core)
下载安装包
linux内核官网:https://www.kernel.org/
[root@localhost ~]
链接:https://pan.baidu.com/s/1QSc_PeVsj6olE6vIrRScYQ 提取码:w1g2
编译内核
选择配置项的方式有以下几种,选择哪种都可以。
make config (基于文本的配置界面)
make menuconfig (基于文本菜单的配置界面)
make xconfig (基于图形窗口的配置界面)
make oldconfig (基于原来内核配置的基础上修改)
以上几种:
使用 make menuconfig 需要 ncurses-devel 的支持,如果之前没装过,需要执行下面的命令安装一下。
[root@localhost ~]
[root@localhost ~]
[root@localhost linux-4.14.196]
[root@localhost ~]
[root@localhost linux-4.14.196]
![在这里插入图片描述]()
Linux 内核所有的配置项都在这里,内核的编译分为两个部分,核心和模块,对于核心的部分,要编译进核心,可能以后会用到的部分,尽量编译成模块。
文本菜单选择界面,使用左(←)、右(→)箭头切换底部菜单,上(↑)、下(↓)箭头切换中间的配置项,空格键 选择配置项,部分配置项右边有 —> 标识,代表有下级子项,可以使用 Enter 进去选择。
同时每一项的前面都有以下标识,可以根据需要选择。
- <*>[*] 表示编译进核心
- <M> 表示编译成模块
- 空格 表示不选中此项
如果你只是看一下整个编译过程,不想深究每一项,执行上一步 make menuconfig 之后,直接保存退出就可以了,它会使用 CentOS 内部的配置文件作为这次编译的配置文件
[root@localhost linux-4.14.196]
[root@localhost linux-4.14.196]
[root@localhost linux-4.14.196]
[root@localhost linux-4.14.196]
total 201364
-rw-r--r--. 1 root root 151918 Nov 9 2018 config-3.10.0-957.el7.x86_64
drwxr-xr-x. 3 root root 17 Jun 30 18:04 efi
drwxr-xr-x. 2 root root 4096 Sep 9 14:06 extlinux
drwxr-xr-x. 2 root root 27 Jun 30 18:05 grub
drwx------. 5 root root 97 Sep 9 19:07 grub2
-rw-------. 1 root root 57430086 Jun 30 18:08 initramfs-0-rescue-502ad5c8bfc847fea2cacceff257adae.img
-rw-------. 1 root root 22417877 Jun 30 18:09 initramfs-3.10.0-957.el7.x86_64.img
-rw-------. 1 root root 98006427 Sep 9 19:07 initramfs-4.14.196.img
-rw-r--r--. 1 root root 314036 Nov 9 2018 symvers-3.10.0-957.el7.x86_64.gz
lrwxrwxrwx. 1 root root 25 Sep 9 19:04 System.map -> /boot/System.map-4.14.196
-rw-------. 1 root root 3543471 Nov 9 2018 System.map-3.10.0-957.el7.x86_64
-rw-r--r--. 1 root root 3498834 Sep 9 19:04 System.map-4.14.196
lrwxrwxrwx. 1 root root 22 Sep 9 19:04 vmlinuz -> /boot/vmlinuz-4.14.196
-rwxr-xr-x. 1 root root 6639904 Jun 30 18:08 vmlinuz-0-rescue-502ad5c8bfc847fea2cacceff257adae
-rwxr-xr-x. 1 root root 6639904 Nov 9 2018 vmlinuz-3.10.0-957.el7.x86_64
-rw-r--r--. 1 root root 7517472 Sep 9 19:04 vmlinuz-4.14.196
更新启动引导
[root@localhost linux-4.14.196]
0 : CentOS Linux (4.14.196) 7 (Core)
1 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-502ad5c8bfc847fea2cacceff257adae) 7 (Core)
[root@localhost linux-4.14.196]
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.14.196
Found initrd image: /boot/initramfs-4.14.196.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-502ad5c8bfc847fea2cacceff257adae
Found initrd image: /boot/initramfs-0-rescue-502ad5c8bfc847fea2cacceff257adae.img
done
修改默认启动内核
[root@localhost ~]
saved_entry=CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
[root@localhost ~]
0 : CentOS Linux (4.14.196) 7 (Core)
1 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-502ad5c8bfc847fea2cacceff257adae) 7 (Core)
[root@localhost ~]
[root@localhost ~]
saved_entry=CentOS Linux (4.14.196) 7 (Core)
重启之后验证
[root@localhost ~]
[root@localhost ~]
4.14.196