方法一

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 安装所需依赖包
sudo apt install build-essential libncurses5-dev fakeroot xz-utils
sudo apt install flex libdaemon-dev libbison-dev libelf-dev
sudo apt-get install libssl-dev
sudo apt-get install dwarves

# 去官网下载你想要安装的内核版本,然后解压到/lib/modules目录下
cd 内核源码文件夹

# 创建内核配置文件
sudo make menuconfig

# 编译内核源码
sudo make -j16

# 内核模块安装
sudo make modules_install

# 内核安装
sudo make install

方法二

1
2
3
4
5
6
7
8
9
# 拷贝原来的内核配置文件
sudo cp /boot/config-`uname -r`* .config

# 配置内核
sudo make defconfig

# 编译内核并安装
sudo make -j$(nproc)
sudo make modules_install install

ps:方法一和方法二我都试过,可以成功安装

记录一下安装内核处理过的错误:

(111条消息) 编译内核报错 No rule to make target ‘debian/canonical-certs.pem‘ 或 ‘canonical-revoked-certs.pem‘ 的解决方法_lylhw13_的博客-CSDN博客

1
2
3
sudo scripts/config --disable SYSTEM_TRUSTED_KEYS
sudo scripts/config --disable SYSTEM_REVOCATION_KEYS
sudo make # sudo make V=1 all

参考

https://blog.csdn.net/SweeNeil/article/details/83684565
https://blog.csdn.net/qq_42793254/article/details/103074998

切换内核版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 查看可用内核信息
grep menuentry /boot/grub/grub.cfg

sudo vim /etc/default/grub
# 写入GRUB_DEFAULT="Advanced options for Ubuntu > Ubuntu, with Linux 4.18.0-18-generic"
# 其中Linux 4.18.0-18-generic为你想切换到的版本

sudo update-grub

# 然后重启电脑
sudo reboot

# 查看当前内核版本
uname -r