diff --git a/backend.py b/backend.py index 10fd89d..34f949b 100644 --- a/backend.py +++ b/backend.py @@ -2198,11 +2198,18 @@ def chroot_and_repair_grub(mount_point: str, target_disk: str, # 检查 /boot 是否已挂载(在 chroot 内) success, stdout, _ = run_command( - chroot_cmd_prefix + ["mount", "|", "grep", "boot"], - "检查 /boot 挂载状态", + chroot_cmd_prefix + ["mount"], + "检查挂载状态", timeout=5 ) - log_info(f"/boot 挂载状态: {stdout if success else '未显示或检查失败'}") + if success: + boot_mounts = [line for line in stdout.split('\n') if 'boot' in line.lower()] + if boot_mounts: + log_info(f"/boot 挂载状态: {', '.join(boot_mounts)}") + else: + log_info("/boot 挂载状态: 未找到相关挂载") + else: + log_info("/boot 挂载状态: 检查失败") # 方法1: 使用 grub2-editenv 创建 editenv_cmd = None