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

安装*.deb:

sudo dpkg -i *.deb

更新grub:

sudo update-grub

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

grep submenu /boot/grub/grub.cfg

如下:

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

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

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

grep gnulinux /boot/grub/grub.cfg
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' {

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

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

vim /etc/default/grub

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

GRUB_DEFAULT=0

改为:

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

5 更新grub:

sudo update-grub

6 重启

查看系统内核版本:

uname -r

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

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

你可能感兴趣的:(笔记,Ubuntu系统配置,linux,ubuntu)