Ubuntu22.04系统切换内核版本

Ubuntu系统切换内核版本

  • [1 更换镜像源](#1 更换镜像源)
  • [2 查询可更换的内核版本](#2 查询可更换的内核版本)
  • [3 安装合适版本内核](#3 安装合适版本内核)
  • [4 切换内核版本](#4 切换内核版本)
  • [5 验证内核是否更换成功](#5 验证内核是否更换成功)

1 更换镜像源

使用鱼香ROS脚本来更换镜像源

wget http://fishros.com/install -O fishros && . fishros

2 查询可更换的内核版本

sudo apt update
sudo apt search linux-image

3 安装合适版本内核

此处选择linux-image-6.2.0-37-generic

# 内核镜像
sudo apt install linux-image-6.2.0-37-generic
# 内核头文件
sudo apt install linux-headers-6.2.0-37-generic
# 内核模块
sudo apt install linux-modules-6.2.0-37-generic
# 内核额外模块
sudo apt install linux-modules-extra-6.2.0-37-generic

查看是否安装成功

dpkg -l | grep linux-image      

4 切换内核版本

查看内核版本的顺序

gedit /boot/grub/grub.cfg

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
	recordfail
	load_video
	gfxmode $linux_gfx_mode
	insmod gzio
	if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
	insmod part_gpt
	insmod ext2
	set root='hd0,gpt3'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
	else
	  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
	fi
	linux	/boot/vmlinuz-6.8.0-51-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro  quiet splash $vt_handoff
	initrd	/boot/initrd.img-6.8.0-51-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
	menuentry 'Ubuntu, with Linux 6.8.0-51-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.8.0-51-generic-advanced-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		gfxmode $linux_gfx_mode
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.8.0-51-generic ...'
		linux	/boot/vmlinuz-6.8.0-51-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro  quiet splash $vt_handoff
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.8.0-51-generic
	}
	menuentry 'Ubuntu, with Linux 6.8.0-51-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.8.0-51-generic-recovery-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.8.0-51-generic ...'
		linux	/boot/vmlinuz-6.8.0-51-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro recovery nomodeset dis_ucode_ldr 
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.8.0-51-generic
	}
	menuentry 'Ubuntu, with Linux 6.2.0-37-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.2.0-37-generic-advanced-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		gfxmode $linux_gfx_mode
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.2.0-37-generic ...'
		linux	/boot/vmlinuz-6.2.0-37-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro  quiet splash $vt_handoff
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.2.0-37-generic
	}
	menuentry 'Ubuntu, with Linux 6.2.0-37-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.2.0-37-generic-recovery-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.2.0-37-generic ...'
		linux	/boot/vmlinuz-6.2.0-37-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro recovery nomodeset dis_ucode_ldr 
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.2.0-37-generic
	}
	menuentry 'Ubuntu, with Linux 6.2.0-26-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.2.0-26-generic-advanced-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		gfxmode $linux_gfx_mode
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.2.0-26-generic ...'
		linux	/boot/vmlinuz-6.2.0-26-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro  quiet splash $vt_handoff
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.2.0-26-generic
	}
	menuentry 'Ubuntu, with Linux 6.2.0-26-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.2.0-26-generic-recovery-03c538ec-639b-49ff-b89a-ed6c2ddb6a73' {
		recordfail
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		set root='hd0,gpt3'
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		else
		  search --no-floppy --fs-uuid --set=root 03c538ec-639b-49ff-b89a-ed6c2ddb6a73
		fi
		echo	'Loading Linux 6.2.0-26-generic ...'
		linux	/boot/vmlinuz-6.2.0-26-generic root=UUID=03c538ec-639b-49ff-b89a-ed6c2ddb6a73 ro recovery nomodeset dis_ucode_ldr 
		echo	'Loading initial ramdisk ...'
		initrd	/boot/initrd.img-6.2.0-26-generic
	}
}

可总结如下,所要切换的Ubuntu, with Linux 6.2.0-37-generic"1 > 2"

0   Ubuntu          
1   Ubuntu 高级选项  
	   1>0  Ubuntu, with Linux 6.8.0-51-generic
	   1>1	Ubuntu, with Linux 6.8.0-51-generic (recovery mode)
   	   1>2	Ubuntu, with Linux 6.2.0-37-generic
	   1>3  Ubuntu, with Linux 6.2.0-37-generic (recovery mode)
       1>4	Ubuntu, with Linux 6.2.0-26-generic
   	   1>5	Ubuntu, with Linux 6.2.0-26-generic (recovery moe)

更改grub默认启动项

sudo gedit /etc/default/grub

更新开启引导文件

sudo update-grub

重启

reboot

5 验证内核是否更换成功

uanme -r
相关推荐
流星白龙3 小时前
【Linux】13.Linux进程概念(2)
linux·运维·服务器
余额不足121384 小时前
Linux 操作二:文件映射与文件状态
android·linux·服务器
一个小坑货4 小时前
CentOS 9 Stream 上安装飞书客户端
linux·centos·飞书
缘友一世5 小时前
epoll 的边缘触发(Edge Triggered)与水平触发(Level Triggered)
linux·网络
一往.无前~5 小时前
【无标题】
linux·运维·服务器
舰长1155 小时前
麒麟服务器安装最新 neo4j/5.9.0 图数据库
linux·运维·服务器
Wanliang Li6 小时前
Linux电源管理——Device Power Management Interface
linux·嵌入式·virtio·电源管理·suspend
fulufulucode7 小时前
【Linux】线程与同步互斥相关知识详细梳理
linux·服务器·开发语言
躺不平的理查德7 小时前
shell-特殊位置变量
linux·运维·服务器·bash