From 7b20993078c5b2e99c1d20932472d2832da07750 Mon Sep 17 00:00:00 2001 From: zj <1052308357@qq.com> Date: Thu, 12 Feb 2026 03:19:49 +0800 Subject: [PATCH] 18 --- backend.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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