1. yum 安裝更新內核
(1.1) 添加ELRepo gpg key到系統
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
(1.2) 添加ELRepo到系統
rpm -Uvh https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
(1.3) 查看啓用的Repo
yum repolist
(1.4) 列出可用內核安裝包並部署指定版本
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --enablerepo="elrepo-kernel" install kernel-lt.x86_64 kernel-lt-devel.x86_64
2. 配置Grub2
(2.1) 查看系統是BIOS還是UEFIi啓動
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
(2.2) 查看系統可用的內核版本
awk -F "'" '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
awk -F "'" '$1=="menuentry " {print i++ " : " $2}' /etc/grub2-efi.cfg
(2.3 ) BISO啓動方式下,配置默認啓用內核版本
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
(2.4) UEFI啓動方式下,配置默認啓用內核版本
grub2-set-default 0
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
reboot
(2.5) 驗證系統是否使用新版本內核
uname -snr
3. 清除舊版本內核
(3.1) 安裝yum管理工具yum-utils
yum install yum-utils
(3.2) 移除舊版本內核(新內核運行一段時間後,在執行這個步驟)
package-cleanup --oldkernels
4. 查看系統安裝時間
ls -lact --full-time /etc | tail -1 | awk '{print $6,$7}'