通常在编译安装新内核完成后,系统默认启动的仍是旧内核,你须要告诉系统我要启动新内核,系统才会启动新内核,因此在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
|
能够看出如今默认启动的内核为最新内核!