在 Debian 系统中,随着内核更新,旧内核会不断积累,占用 /boot 空间,可能导致更新失败或磁盘空间不足。下面是安全、常用、推荐的清理旧内核的方法。
千万不要删除正在运行的内核!
uname -r
例如输出:
6.1.0-21-amd64
dpkg --list | grep linux-image
或:
ls /boot/vmlinuz-*
apt 自动清理(最安全 ✅)sudo apt autoremove --purge
Debian 会自动:
✅ 这是最推荐的方法
apt list --installed | grep linux-image
sudo apt purge linux-image-6.1.0-18-amd64
或同时删除头文件:
sudo apt purge linux-image-6.1.0-18-amd64 linux-headers-6.1.0-18-amd64
grub-pc(常见于 Debian)更新 GRUB:
sudo update-grub
/boot 空间不足时的应急方案 ⚠️/boot 使用情况df -h /boot
ls /boot
删除旧版本(不要删当前内核):
sudo rm /boot/vmlinuz-6.1.0-18-amd64
sudo rm /boot/initrd.img-6.1.0-18-amd64
sudo rm /boot/System.map-6.1.0-18-amd64
sudo rm /boot/config-6.1.0-18-amd64
然后修复依赖:
sudo apt -f install
Debian 12+ 通常已自动管理,但你可以检查:
cat /etc/apt/apt.conf.d/01autoremove
✅ 首选
sudo apt update
sudo apt autoremove --purge
sudo update-grub
⚠️ 手动删除仅用于特殊情况
如果你愿意,可以贴出:
uname -r
dpkg --list | grep linux-image
我可以帮你判断哪些内核可以安全删除。