当前位置:   article > 正文

Ubuntu切换指定版本的内核

Ubuntu切换指定版本的内核

本文参考:马春杰杰的博客
想切换不同系统内核怎么办?按下面步骤即可:

1 安装指定版本的Ubuntu 的内核:

http://kernel.ubuntu.com/~kernel-ppa/mainline/中选择需要的版本:
根据你的系统架构下载 *.deb 文件:

wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.180/amd64/linux-headers-5.4.180-0504180_5.4.180-0504180.202202161239_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.180/amd64/linux-headers-5.4.180-0504180-generic_5.4.180-0504180.202202161239_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.180/amd64/linux-image-unsigned-5.4.180-0504180-generic_5.4.180-0504180.202202161239_amd64.deb
  • 1
  • 2
  • 3

安装*.deb:

sudo dpkg -i *.deb
  • 1

更新grub:

sudo update-grub
  • 1

2 确定当前使用的内核id:

grep submenu /boot/grub/grub.cfg
  • 1

如下:

submenu 'Ubuntu 高级选项' $menuentry_id_option 'gnulinux-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
  • 1

将单引号中的id记录下来gnulinux-advanced-3f5e97d5-cd08-4560-94df-613149aac32e

3 查找想要使用的内核id :

grep gnulinux /boot/grub/grub.cfg
  • 1
set default="gnulinux-advanced-3f5e97d5-cd08-4560-94df-613149aac32e>gnulinux-4.4.248-0404248-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e"
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-3f5e97d5-cd08-4560-94df-613149aac32e' {
submenu 'Ubuntu 高级选项' $menuentry_id_option 'gnulinux-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu,Linux 4.15.1-041501-lowlatency' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-lowlatency-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.15.1-041501-lowlatency (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-lowlatency-init-upstart-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.15.1-041501-lowlatency (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-lowlatency-recovery-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu,Linux 4.15.1-041501-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.15.1-041501-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-generic-init-upstart-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.15.1-041501-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.1-041501-generic-recovery-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu,Linux 4.4.248-0404248-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.248-0404248-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.4.248-0404248-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.248-0404248-generic-init-upstart-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.4.248-0404248-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.248-0404248-generic-recovery-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu,Linux 4.4.0-141-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-141-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.4.0-141-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-141-generic-init-upstart-3f5e97d5-cd08-4560-94df-613149aac32e' {
        menuentry 'Ubuntu, with Linux 4.4.0-141-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-141-generic-recovery-3f5e97d5-cd08-4560-94df-613149aac32e' {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

选择我们想要切换的内核,这里我选择的为:gnulinux-4.4.248-0404248-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e

4 修改grub文件,切换内核:

vim /etc/default/grub
  • 1

根据第二步和第三步得到的内核:

GRUB_DEFAULT=0
  • 1

改为:

GRUB_DEFAULT="gnulinux-advanced-3f5e97d5-cd08-4560-94df-613149aac32e>gnulinux-4.4.248-0404248-generic-advanced-3f5e97d5-cd08-4560-94df-613149aac32e"
  • 1

5 更新grub:

sudo update-grub
  • 1

6 重启

查看系统内核版本:

uname -r
  • 1

7 安装指定内核版本其他方法

参考之前的帖子:Ubuntu安装指定版本的内核

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/129433?site
推荐阅读
相关标签
  

闽ICP备14008679号