在 Debian 中“替换默认内核”通常有两种含义,下面分别说明,并给出常用做法。
dpkg -l | grep linux-image
# 或
ls /boot/vmlinuz-*
例如安装官方仓库中的某个版本:
sudo apt update
sudo apt install linux-image-6.1.0-xx-amd64
如果是自己编译或第三方内核,也会生成 linux-image-* 包。
grep '^menuentry' /boot/grub/grub.cfg
或(UEFI 常见):
grep '^menuentry' /boot/grub/grub.cfg | nl
编辑 GRUB 配置:
sudo nano /etc/default/grub
修改或添加:
GRUB_DEFAULT=0
0 表示第一个菜单项GRUB_DEFAULT="Advanced options for Debian>Debian GNU/Linux, with Linux 6.1.0-xx-amd64"
sudo update-grub
sudo reboot
确认:
uname -r
⚠️ 至少保留一个可用内核
sudo apt remove linux-image-5.10.0-xx-amd64
sudo apt autoremove
卸载后 GRUB 通常会自动把新内核设为默认。
grub-set-default(持久设置)sudo grub-set-default "Debian GNU/Linux, with Linux 6.1.0-xx-amd64"
sudo update-grub
查看当前默认:
grub-editenv list
如果你使用的是 systemd-boot 而非 GRUB:
bootctl list
sudo bootctl set-default xxx.conf
update-grubgrub-reboot 临时指定一次启动如果你能说明:
cat /etc/debian_version)我可以给你更精确的步骤。