Ubuntu安装/切换内核

查看当前已安装的内核

$ sudo dpkg --get-selections |grep linux-image
linux-image-5.15.0-71-generic install
linux-image-5.15.0-72-generic install
linux-image-5.4.0-149-generic install
linux-image-generic-hwe-20.04 install

安装指定版本内核

Install kernel-generic:通用内核,一般 PC 及 Server

sudo apt list linux-headers-5.15.*-*-generic linux-image-5.15.*-*-generic
sudo apt install linux-headers-5.15.*-*-generic linux-image-5.15.*-*-generic

Install low-latency kernel:低延迟内核,适用于工业嵌入式系统(Industrial embedded systems)

sudo apt list linux-headers-5.15.*-*-lowlatency linux-image-5.15.*-*-lowlatency
sudo apt install linux-headers-5.15.*-*-lowlatency linux-image-5.15.*-*-lowlatency

更新initramfs

sudo update-initramfs -u -k all

修改引导菜单

/etc/default/grub

GRUB_DEFAULT=0
# GRUB_TIMEOUT_STYLE=hidden >>>>>>>>>>>注释该行 显示grub菜单
GRUB_TIMEOUT=20 >>>>>>>>>>>设置菜单超时时长
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

sudo update-grub

reboot
通过grub菜单进入使用新内核的系统
sudo apt autoremove
卸载掉旧内核

检查内核启动顺序
grep menuentry /boot/grub/grub.cfg
编辑默认启动内核
vim /etc/default/grub
GRUB_DEFAULT=0
# 改为
修改GRUB_DEFAULT的值为"1>2"
# 或者
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-42-generic"
sudo update-grub
reboot
uname -r # 检查
posted @   ishmaelwanglin  阅读(3539)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示