通常在編譯安裝新內核完成後,系統默認啓動的仍是舊內核,你須要告訴系統我要啓動新內核,系統纔會啓動新內核,因此在linux中,你須要更改配置文件告知它!
linux
#在這裏我使用的最新內核爲4.4.0vim
一.首先查看默認啓動的內核
bash
1
|
[root@localhost ~]
# uname -r
|
二.查看新內核在配置文件中的順序ide
1 |
[root@localhost ~]
# cat /boot/grub2/grub.cfg
|
此順序用來決定開機時的排列順序,能夠看出4.4.0內核順序是0(啓動順序是按0、一、2進行排列)。spa
三.修改配置文件,改變優先級3d
將GRUB_DEFAULT=saved 改爲 GRUB_DEFAULT=0code
1
2
3
4
5
6
7
8
|
[root@localhost ~]
# vim /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=
"$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=
true
GRUB_TERMINAL_OUTPUT=
"console"
GRUB_CMDLINE_LINUX=
"rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
GRUB_DISABLE_RECOVERY=
"true"
|
四.使其配置文件生效
orm
1
2
3
4
5
6
7
8
9
|
[root@localhost ~]
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration
file
...
Found linux p_w_picpath:
/boot/vmlinuz-4
.4.0
Found initrd p_w_picpath:
/boot/initramfs-4
.4.0.img
Found linux p_w_picpath:
/boot/vmlinuz-3
.10.0-327.el7.x86_64
Found initrd p_w_picpath:
/boot/initramfs-3
.10.0-327.el7.x86_64.img
Found linux p_w_picpath:
/boot/vmlinuz-0-rescue-829121a948844a7bb4878c430993b60a
Found initrd p_w_picpath:
/boot/initramfs-0-rescue-829121a948844a7bb4878c430993b60a
.img
done
|
五.修改先後的對比blog
1
|
[root@localhost ~]
# cat /boot/grub2/grub.cfg
|
修改前:
修改後:
六.重啓驗證
1
|
[root@localhost ~]
# uname -r
|
能夠看出如今默認啓動的內核爲最新內核!