在Red Hat EL版本5和6中,我们可以很容易地更新/etc/grub.conf ,以防我们想要通过默认variables来更改内核
For example , grub.conf on redhat 5 default=0 timeout=5 #splashimage=(hd0,0)/grub/splash.xpm.gz #hiddenmenu title Red Hat Enterprise Linux Server (2.6.18-410.el5) root (hd0,0) kernel /vmlinuz-2.6.18-410.el5 ro root=/dev/rootvg/slash initrd /initrd-2.6.18-410.el5.img title Red Hat Enterprise Linux Server (2.6.18-409.el5) root (hd0,0) kernel /vmlinuz-2.6.18-409.el5 ro root=/dev/rootvg/slash initrd /initrd-2.6.18-409.el5.img
从这个/etc/grub.conf如果我们想从内核2.6.18-409版本启动,那么我们只需要改变default=1 。 所以在下一次启动时,操作系统将从旧的内核开始
RHEL7是非常不同的。 我在RHEL7中find/boot/grub2/grub.cfg但是我不明白如何改变文件以便从其他内核启动,就像我在RHEL5上做的一样。
将/etc/default/grub中的GRUB_DEFAULT=0更改为所需的数字,现在需要使用grub2-mkconfig -o /boot/grub2/grub.cfgconfigurationgrub2configuration
如何在redhat 7版本上更改GRUB内核
要列出将在系统引导时显示的所有菜单条目,请发出以下命令:
# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 0 : Red Hat Enterprise Linux Server (3.10.0-327.18.2.el7.x86_64) 7.2 (Maipo) 1 : Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo) 2 : Red Hat Enterprise Linux Server, with Linux 0-rescue- b2c5e6a1c5ea4cb5be82100bd7dc3469
如何validation当前条目是什么(当前内核来自/ etc / default / grub)
# grub2-editenv list saved_entry=1
这意味着从grubconfiguration的当前内核版本是: 3.10.0-327.10.1.el7.x86_64
让我们来看看机器上当前的内核版本是什么:
# uname -r 3.10.0-327.10.1.el7.x86_64
现在让我们从GRUBconfiguration中更改内核版本,以便Linux以更高的内核启动 – 3.10.0-327.18.2.el7.x86_64,
记得从awk命令我们得到的编号为0
所以设置应该如下
# grub2-set-default 0
现在我们通过检查新的GRUBconfiguration
# grub2-editenv list saved_entry=0
所以现在将新的GRUBconfiguration设置为内核版本: 3.10.0-327.18.2.el7.x86_64
现在我们重启机器
# Reboot
重新启动后,Linux与新的内核
# uname -r 3.10.0-327.18.2.el7.x86_64