grub2在bios+mbr模式下需bios boot分区(ef02类型,1–2mib)存放core.img;chroot中需挂载/proc、/sys、/dev及/boot;update-grub依赖os-prober且需启用并挂载目标分区;uefi模式需确认/sys/firmware/efi存在并挂载esp。

grub-install 命令执行失败:/dev/sda 没有 BIOS Boot 分区
这是 GRUB2 在 BIOS + MBR 模式下最常卡住的地方。GRUB2 的核心镜像(core.img)太大,无法塞进 MBR 后面那 512 字节的“空隙”,必须依赖一个专用的 BIOS Boot Partition(类型为 EF02,不挂载、无文件系统)来存放它。
- 用
fdisk -l /dev/sda查看分区表,确认是否存在类型为BIOS boot的小分区(通常 1–2 MiB) - 如果没有,进
fdisk /dev/sda→n新建分区 →t改类型 → 输入ef02→w写入 - 再运行
grub-install --target=i386-pc /dev/sda,否则会报错embedding is not possible
chroot 环境里 grub-install 报错 unknown filesystem
说明 grub-install 找不到根文件系统里的 /boot 或 /boot/grub,常见于没正确挂载 /boot、/dev、/proc、/sys 就直接 chroot。
- 确保宿主机中已挂载目标系统的根分区到
/mnt,且/boot是独立分区时也挂载到了/mnt/boot - 依次执行:
mount -t proc /proc /mnt/proc、mount -t sysfs /sys /mnt/sys、mount -o bind /dev /mnt/dev - 进入 chroot 后先运行
ls /boot/grub/i386-pc/,看到一堆*.mod文件才算环境就绪,再跑grub-install
update-grub 找不到 Windows 或其他 Linux 系统
update-grub 本质是调用 os-prober 扫描其他启动项,而它默认禁用——尤其在较新发行版(如 Ubuntu 22.04+、Debian 12)中,GRUB_DISABLE_OS_PROBER=true 是默认配置。
- 检查
/etc/default/grub中是否含GRUB_DISABLE_OS_PROBER=true,如有,改为false或直接删掉这行 - 确保目标系统分区已挂载(
os-prober不扫描未挂载设备),比如 Windows 的 EFI 分区需挂载到/boot/efi或临时路径 - 运行
os-prober命令手动测试,若输出为空,说明分区未识别或 NTFS 驱动未加载(modprobe ntfs3或安装ntfs-3g)
UEFI 模式下 grub-install 提示 “EFI variables are not supported on this system”
说明当前运行环境不是 UEFI 启动,或者内核没启用 EFI 运行时支持。即使机器是 UEFI 主板,Live 系统也可能以 BIOS 模式启动,导致 /sys/firmware/efi 目录不存在。
- 先确认是否真在 UEFI 下:运行
ls /sys/firmware/efi/efivars,有内容才可继续;否则重启进 UEFI 设置,关闭 CSM/Legacy Boot - 挂载 EFI 系统分区(通常是 FAT32,标签为
ESP)到/mnt/boot/efi,且确保该分区有boot/efi目录结构 - 运行
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu(注意路径是 chroot 内的相对路径)
真正麻烦的从来不是命令敲错,而是搞不清当前启动模式、分区挂载状态和 GRUB 的 target 对应关系。多看一眼 ls /sys/firmware/efi 和 fdisk -l 输出,比反复重装快得多。










