openkylin 2.0sp2运行 update-grub提示/boot/grub/ 目录不存在

2025.8.31

openkylin 2.0sp2 amd64

一、操作
root@wo:~# update-grub

输出:
Sourcing file `/etc/default/grub’
/usr/sbin/grub-mkconfig: 278: cannot create /boot/grub/grub.cfg.new: Directory nonexistent

原因推测:

  1. 应该是在 安装/卸载 某个版本的内核包时,
    比如
  • linux-image-unsigned-6.6.0-15-generic
  • linux-image-unsigned-6.6.0-17-generic
  • linux-image-5.15.0-23-generic

内核包里的 postinst 和 postrm 安装脚本,使用了递归删除 (或者 强制删除) /boot/grub/ 目录的指令。比如:
rmdir -p /boot/grub/
或者
rm -R /boot/grub/grub.cfg*

  1. 管理员命令 /usr/sbin/grub-mkconfig ,没有保留自动检测、创建
    /boot/grub/ 目录的指令?

:)