This commit is contained in:
zj
2026-02-12 03:59:50 +08:00
parent 6587f3783e
commit 19cff55298

View File

@@ -2460,10 +2460,30 @@ def chroot_and_repair_grub(mount_point: str, target_disk: str,
content = f.read()
menu_entries = content.count('menuentry')
log_info(f" 发现 {menu_entries} 个启动菜单项")
# 验证配置文件是否有效
if size < 1000:
log_warning(f"配置文件太小 ({size} 字节),可能有问题")
if menu_entries == 0:
log_warning("配置文件中没有找到启动菜单项!")
log_info("尝试重新生成配置...")
# 再次尝试生成配置
success2, stdout2, stderr2 = run_command(
chroot_cmd_prefix + grub_update_cmd,
"重新生成GRUB配置",
timeout=120
)
if success2:
# 重新读取
with open(full_config_path, 'r') as f2:
content2 = f2.read()
menu_entries2 = content2.count('menuentry')
log_info(f"重新生成后: {len(content2)} 字节, {menu_entries2} 个菜单项")
except Exception as e:
log_warning(f" 无法读取配置文件: {e}")
else:
log_warning(f" 配置文件未找到: {full_config_path}")
return False, f"grub.cfg 文件未生成: {full_config_path}"
# ===== 输出启动提示 =====
if is_uefi or install_hybrid: