查看内核
uname -r
设置内核源
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
查看可用系统内核包
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
以下为可用的内核包
kernel-lt.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.192-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
perf.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.2.14-1.el7.elrepo elrepo-kernel
安装最新内核
yum --enablerepo=elrepo-kernel install kernel-ml
设置内核
更新内核
grub2-mkconfig -o /boot/grub2/grub.cfg
输出
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.2.14-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.2.14-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.21.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.21.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.5.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.5.1.el7.x86_64.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-4284cfe27c5b48c38adde30f33b4bb60
Found initrd image: /boot/initramfs-0-rescue-4284cfe27c5b48c38adde30f33b4bb60.img
done
查看系统内核
cat /boot/grub2/grub.cfg |grep menuentry
输出
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-5.2.14-1.el7.elrepo.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.21.3.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.5.1.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (0-rescue-4284cfe27c5b48c38adde30f33b4bb60) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-4284cfe27c5b48c38adde30f33b4bb60-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
设置内核
设置默认内核(注意上面的输出)
grub2-set-default "CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)"
验证
grub2-editenv list
输出(下面说明设置成功)
saved_entry=CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)
重启电脑
reboot
查看内核
uname -r
输出
5.2.14-1.el7.elrepo.x86_64