debian
看当前系统内核
cat /boot/grub/grub.cfg | grep menuentry
if [ x”${feature_menuentry_id}” = xy ]; then
menuentry_id_option=”–id”
menuentry_id_option=””
export menuentry_id_option
menuentry ‘Debian GNU/Linux’ –class debian –class gnu-linux –class gnu –class os $menuentry_id_option ‘gnulinux-simple-cdd695b0-e558-4915-ba1d-38c769fee1b1’ {
submenu ‘Advanced options for Debian GNU/Linux’ $menuentry_id_option ‘gnulinux-advanced-cdd695b0-e558-4915-ba1d-38c769fee1b1’ {
menuentry 'Debian GNU/Linux, with Linux 4.9.0-12-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.0-12-amd64-advanced-cdd695b0-e558-4915-ba1d-38c769fee1b1' {
menuentry 'Debian GNU/Linux, with Linux 4.9.0-12-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.0-12-amd64-recovery-cdd695b0-e558-4915-ba1d-38c769fee1b1' {
menuentry 'Debian GNU/Linux, with Linux 4.9.0-11-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.0-11-amd64-advanced-cdd695b0-e558-4915-ba1d-38c769fee1b1' {
menuentry 'Debian GNU/Linux, with Linux 4.9.0-11-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.9.0-11-amd64-recovery-cdd695b0-e558-4915-ba1d-38c769fee1b1' {
修改grub文件
假设修改启动内核为4.9.0-11,修改文件/etc/default/grub。
sudo vim /etc/default/grub
GRUB_DEFAULT=0
修改为
GRUB_DEFAULT=”Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 4.9.0-11-amd64″
其中Advanced options for Debian GNU/Linux是一级菜单,Debian GNU/Linux, with Linux 4.9.0-11-amd64是二级菜单,两者之间用>连接。
更新grub文件
sudo update-grub
重启
重启之后使用uname -r可以查看当前的系统内核。
CentOS
查看当前系统内核
sudo awk -F’ ‘$1==”menuentry ” {print $2}’ /etc/grub2.cfg
CentOS Linux (3.10.0-1062.18.1.el7.x86_64) 7 (Core)
CentOS Linux 7 Rescue 37934a904e9234509c00524a5e733795 (3.10.0-1062.18.1.el7.x86_64)
CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-65113b1a0d2f6087d515e6a8cd0ee7ef) 7 (Core)
设置默认启动内核
假设修改启动内核为3.10.0-957.27.2。
grub2-set-default ‘CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)’
重启
重启之后使用uname -r可以查看当前的系统内核。