自学内容网 自学内容网

Ubuntu22.04系统切换内核版本

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>1Ubuntu, with Linux 6.8.0-51-generic (recovery mode)
      1>2Ubuntu, with Linux 6.2.0-37-generic
   1>3  Ubuntu, with Linux 6.2.0-37-generic (recovery mode)
       1>4Ubuntu, with Linux 6.2.0-26-generic
      1>5Ubuntu, with Linux 6.2.0-26-generic (recovery moe)

更改grub默认启动项

sudo gedit /etc/default/grub

在这里插入图片描述
更新开启引导文件

sudo update-grub

重启

reboot

5 验证内核是否更换成功

uanme -r

原文地址:https://blog.csdn.net/qq_41889342/article/details/145227589

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!