内核版本"/>
RHEL7升级内核版本
按指定要求安装升级内核,保证grub2启动时为默认项目操作方法
第一步
确认当前操作系统的内核版本
[root@server0 ~]# uname -r
3.10.0-123.el7.x86_64
第二步
下载准备升级的内核文件,比如说内核已存在于某个 Yum 仓库:
.0/x86_64/errata
此时只要添加这个 Yum 源就可以直接下载了。
[root@server0 ~]# yum-config-manager --add-repo=".0/x86_64/errata"
若是第一次配置,还需要导入红帽公钥
[root@server0 ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-*
相关阅读▼显示
第三步
查找内核,并确认 Yum 仓库中的内核是否为需要升级的内核
[root@server0 ~]# yum list kernel
Loaded plugins: langpacks
Installed Packages
kernel.x86_64 3.10.0-123.el7 installed
Available Packages
kernel.x86_64 3.10.0-123.1.2.el7 content.example.com_rhel7.0_x86_64_errata
第四步
安装新的内核,若内核文件很大,那安装时间就相对漫长一些。
[root@server0 ~]# yum -y install kernel
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
--> Package kernel.x86_64 0:3.10.0-123.1.2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================
Package Arch Version Repository Size
=====================================================
Installing:
kernel x86_64 3.10.0-123.1.2.el7 content.example.com_rhel7.0_x86_64_errata 29 M
Transaction Summary
=====================================================
Install 1 Package
Total download size: 29 M
Installed size: 127 M
Downloading packages:
No Presto metadata available for content.example.com_rhel7.0_x86_64_errata
kernel-3.10.0-123.1.2.el7.x86_64.rpm | 29 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : kernel-3.10.0-123.1.2.el7.x86_64 1/1
Verifying : kernel-3.10.0-123.1.2.el7.x86_64 1/1
Installed:
kernel.x86_64 0:3.10.0-123.1.2.el7
Complete!
第五步
检查新内核是否为默认启动内核(若是安装高版本号的内核,默认都会作为优先启动内核)
[root@server0 ~]# grub2-editenv list
saved_entry=Red Hat Enterprise Linux Server (3.10.0-123.1.2.el7.x86_64) 7.0 (Maipo)
当前默认启动内核已经是刚才升级的内核!如果要手动调整内核启动顺序,需要再进行设置一番。
第六步
确认当前操作系统有几个启动内核
[root@server0 ~]# grep "menuentry " /boot/grub2/grub.cfg
menuentry 'Red Hat Enterprise Linux Server (3.10.0-123.1.2.el7.x86_64) 7.0 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-9bf6b9f7-92ad-441b-848e-0257cbb883d1' {
menuentry 'Red Hat Enterprise Linux Server, with Linux 3.10.0-123.el7.x86_64' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-9bf6b9f7-92ad-441b-848e-0257cbb883d1' {
menuentry 'Red Hat Enterprise Linux Server, with Linux 0-rescue-946cb0e817ea4adb916183df8c4fc817' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-946cb0e817ea4adb916183df8c4fc817-advanced-9bf6b9f7-92ad-441b-848e-0257cbb883d1' {
当前操作系统有三个内核,其中第一个内核版本为 3.10.0-123.1.2.el7.x86_64,也就是我们刚才升级的内核;第二个内核版本为 3.10.0-123.el7.x86_64,是最初查看的内核版本。
现在设置第二个内核(3.10.0-123.el7.x86_64)为默认启动内核
[root@server0 ~]# grub2-set-default "Red Hat Enterprise Linux Server, with Linux 3.10.0-123.el7.x86_64"
然后确认一下是否设置成功
[root@server0 ~]# grub2-editenv list
saved_entry=Red Hat Enterprise Linux Server, with Linux 3.10.0-123.el7.x86_64
最后就是更新一下配置,让新的内核启动生效
[root@server0 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-946cb0e817ea4adb916183df8c4fc817
Found initrd image: /boot/initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img
done
更多推荐
RHEL7升级内核版本
发布评论