欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Ubuntu 切换系统默认启动内核

程序员文章站 2022-06-22 19:27:34
1.首先找到内核名称。grep menuentry /boot/grub/grub.cfg例如我的最后显示如下,复制所要的内核名称(例如我需要的Ubuntu,Linux 4.15.0-29-generic)。if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" menuentry_id......

1.首先找到内核名称。

grep menuentry /boot/grub/grub.cfg

例如我的最后显示如下,复制所要的内核名称(例如我需要的Ubuntu,Linux 4.15.0-29-generic)。

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-3a45027c-15ed-4cec-a233-7c3927e74d11' {
submenu 'Ubuntu 高级选项' $menuentry_id_option 'gnulinux-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu,Linux 4.15.0-43-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-43-generic-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-43-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-43-generic-init-upstart-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-43-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-43-generic-recovery-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu,Linux 4.15.0-33-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-33-generic-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-33-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-33-generic-init-upstart-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-33-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-33-generic-recovery-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu,Linux 4.15.0-29-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-29-generic-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-29-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-29-generic-init-upstart-3a45027c-15ed-4cec-a233-7c3927e74d11' {
	menuentry 'Ubuntu, with Linux 4.15.0-29-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-29-generic-recovery-3a45027c-15ed-4cec-a233-7c3927e74d11' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-246AF2746AF241DA' {

2.然后修改grub文件中的GRUB_DEFAULT="Ubuntu,Linux 4.15.0-29-generic".

sudo gedit /etc/default/grub

3.sudo update-grub,这时候会有WARNING提示修改GRUB_DEFAULT的名称,例如我的WARNING提示我将GRUB_DEFAULT修改为GRUB_DEFAULT="gnulinux-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11>gnulinux-4.15.0-29-generic-advanced-3a45027c-15ed-4cec-a233-7c3927e74d11"。将该名字复制重新进行步骤二,然后再sudo update-grub。

sudo update-grub

4.重启。

sudo reboot

有些时候,会出现以下情况。

可能第一次重启仍需要进入Ubuntu高级选项选择系统内核,此时选择步骤2中选择的版本的内核,然后进入系统后输入sudo apt-get update,重复步骤4重启,即可切换系统默认启动内核。

本文地址:https://blog.csdn.net/cf_wu95/article/details/85984956

相关标签: linux学习笔记