- 下面介紹CentOS7 通過使用 elrepo 源的方式直接安裝最新穩(wěn)定版 kernel
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y
- 升級(jí)完內(nèi)核战转,自動(dòng)按最新內(nèi)核啟動(dòng)鹦聪,修改以下文件
vim /etc/default/grub
#修改 GRUB_DEFAULT=0
grub2-mkconfig -o /boot/grub2/grub.cfg
UEFI 系統(tǒng)上的指令是 grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
重新編譯內(nèi)核啟動(dòng)文件鬼廓,以后升級(jí)完內(nèi)核也要執(zhí)行一次
若要列出系統(tǒng)開機(jī)時(shí)顯示的所有選項(xiàng)郎逃,請執(zhí)行以下指令:
[root@host ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
缺省的項(xiàng)目是通過 /etc/default/grub 檔內(nèi)的 GRUB_DEFAULT 行來定義泪漂。
不過递宅,要是 GRUB_DEFAULT 行被設(shè)置為 saved,這個(gè)選項(xiàng)便存儲(chǔ)在 /boot/grub2/grubenv 檔內(nèi)锉屈。你可以這樣查看它:
[root@host ~]# grub2-editenv list
saved_entry=CentOS Linux (3.10.0-229.14.1.el7.x86_64) 7 (Core)
- /etc/default/grub 檔內(nèi)另一個(gè)有用的選項(xiàng)是:
GRUB_SAVEDEFAULT=true
/boot/grub2/grubenv 文檔是不能手動(dòng)編輯的荤傲。請采用以下指令:
[root@host ~]# grub2-set-default 0
[root@host ~]# grub2-editenv list
saved_entry=0
- 一切就緒以后
[root@host ~]#reboot
...重新登陸并檢查當(dāng)前運(yùn)行內(nèi)核版本...
[root@host ~]# uname -a
Linux host 4.16.12-1.el7.elrepo.x86_64... x86_64 GNU/Linux
- 還需要手動(dòng)刪除原有內(nèi)核
yum remove kernel -y