如何在Windows分区中安装grub时启动到Windows 7?

原标题:如何解决(un)使用grub在同一分区上启动Windows 7?

我一直在研究这个问题两到三天,但我已经空了。

基本上,分区1是Windows 7,分区2是Ubuntu 12.04。 我告诉Ubuntu安装到分区2并在分区1上安装GRUB,并且工作正常。 但现在的问题是我无法启动Windows 7.它只是在我选择后返回GRUB菜单。

根据我的研究,如果我可以编辑GRUB来启动Windows 7“mbr”或bootloader \windows\system32\winload.exe (不使用Windows 7修复盘),我的问题将得到解决。 这有可能吗?


Boot-Repair-Info的URL是http://paste.ubuntu.com/981952/


命令sudo blkid输出

 /dev/sda1: UUID="1EA0019AA0017A13" TYPE="ntfs" /dev/sda2: UUID="e4402f9e-83df-4dc3-8913-69b28314d253" TYPE="ext4" /dev/sda3: LABEL="Vault Drive" UUID="74145BFD145BC132" TYPE="ntfs" /dev/sda4: UUID="1c030d32-657f-4a78-9468-307d9e09a977" TYPE="ext4" 

您可以使用如下所述的启动修复工具创建Bootinfo摘要报告,然后将链接发布到报告中吗?

我知道您已经提供了有关启动配置的一些详细信息。 但是,我要求的报告包含更详细的信息,可能会让我们更好地了解您无法使用GRUB启动Windows的原因。

如何使用boot-repair提供“Bootinfo Summary”

由于您仍然可以启动Ubuntu,您可以使用apt-get命令安装并运行Boot-Repair工具 ,然后使用它来Create a Bootinfo summary

在终端窗口中运行以下命令以安装boot-repair工具。

 sudo add-apt-repository ppa:yannubuntu/boot-repair sudo apt-get update sudo apt-get install -y boot-repair 
  1. 完成后,输入命令boot-repair以启动该工具。
  2. 稍微延迟后, boot-repair将询问您是否要下载其最新版本。 由于您刚安装了最新版本,请回答No
  3. 如果boot-repair要求安装pastebinit软件包,请回答“ Yes
  4. 该工具现在将扫描您的系统并(最终)显示下图所示的窗口。 单击Create a Bootinfo summary框/按钮。 这将收集有关系统引导配置的信息,但不会进行任何更改。

    初始启动修复窗口

  5. 创建bootinfo摘要后, boot-repair将显示包含URL的消息,该URL应如下所示: http://paste.ubuntu.com/123456/http://paste.ubuntu.com/123456/

    请更新/编辑您的问题并添加此url。 此链接指向的pastebin中的信息(我希望)可以帮助我们诊断问题。


我认为覆盖Windows分区的VBR会导致这个问题。

我的理解是启动操作系统有几个步骤。 在你的情况下,我认为像下面的步骤发生。

  1. 计算机上的BIOS尝试在硬盘驱动器的第一个扇区中运行代码。 第一个扇区通常称为MBR(主引导记录)
  2. 除了MBR之外,每个分区还可以具有引导记录。 它通常被称为卷引导记录或VBR 。 硬盘驱动器上的MBR将控制权转移到Windows分区的分区1的VBR。
  3. Windows希望分区的VBR能够在启动操作系统(如Windows 7)时采取下一步措施。因此,Windows最初会安装一个VBR,它可以将控制权转移到Windows分区中的Windows bootmgr程序。

    但是,当您指示Ubuntu安装程序将GRUB安装到Windows分区时,GRUB似乎已将Windows VBR替换为自己的。 此GRUB VBR显示GRUB引导菜单。

  4. GRUB当前用于启动Windows的指令主要是在Windows分区中定位VBR并将控制权转移给它。 Windows分区中的VBR是GRUB的VBR。 只需(重新)将控制转移到它就会显示GRUB启动菜单。

不幸的是,我不确定解决这个问题的最佳方法是什么。 我们要小心,当我们尝试修复启动Windows的问题时,我们不会破坏GRUB并且无法在计算机上启动任何内容。

以下是Bootinfo摘要中的一些信息的副本,以供参考。 我上面的评论是基于这些信息。

 ============================= Boot Info Summary: =========================== => Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of the same hard drive for core.img. core.img is at this location and looks for (,msdos2)/boot/grub on this drive. sda1: ______________________________________________________________________ File system: ntfs Boot sector type: Grub2 (v1.99) Boot sector info: Grub2 (v1.99) is installed in the boot sector of sda1 and looks at sector 44090872 of the same hard drive for core.img. core.img is at this location and looks for (,msdos2)/boot/grub on this drive. No errors found in the Boot Parameter Block. Operating System: Windows 7 Boot files: /bootmgr /Boot/BCD /Windows/System32/winload.exe sda2: ______________________________________________________________________ File system: ext4 Boot sector type: - Boot sector info: Operating System: Ubuntu 12.04 LTS Boot files: /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img 

一种可能的解决方法来启动Windows 7

以下是编辑GRUB引导命令的建议,这些命令可能允许您启动Windows 7.我不确定这是否可行,但似乎值得尝试。

目前,您的grub.cfg使用下面的GRUB引导命令来启动Windows 7。

 menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 1EA0019AA0017A13 chainloader +1 } 

我建议你尝试更改它并使用这些命令。

 menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 1EA0019AA0017A13 ntldr ($root)/bootmgr } 

以下是执行此操作的步骤。

  1. 将系统引导至GRUB菜单。
  2. 选择(突出显示)GRUB启动菜单项Windows 7 (loader) (on /dev/sda1)
  3. e编辑Windows 7的GRUB引导命令。
  4. 对此命令列表进行两处更改,如上面的menuentry所示。
    • 添加命令insmod ntldr
    • 更改命令
      chainloader +1

      ntldr ($root)/bootmgr
  5. Ctrl + XF10以使用这些编辑的命令启动。

注1:

如果上述解决方案成功加载Windows 7启动菜单,那么您可以使其成为半持久性的

  1. 使用sudo编辑文件/etc/grub.d/40_custom并添加上面显示的第二个修改过的menuentry 。 (如果你这样做,我还建议你改变这个“自定义”条目的标题。)
  2. 运行命令sudo update-grub以更新/boot/grub/grub.cfg以包含您的自定义条目。 (启动时它将位于GRUB菜单的底部。)

我认为上面的建议只是一个部分结合的解决方案。 更好的解决方案是将Windows VBR还原到Windows分区, 而不会破坏GRUB引导的能力。

我认为……但我并非100%确定… Windows恢复命令bootsect可用于执行此操作。 如果您想冒风险,下面概述了一种可行的方法。

  • 启动Windows时,按F8以显示“ Advanced Boot Options菜单。
  • 选择Repair Your Computer条目。
  • 浏览下一个窗口,直到找到System Recovery Options
  • 选择Command Prompt
  • 运行命令bootsect /nt60 C:

但是你可能还想等一下,看看你的问题还有其他答案,然后再冒险尝试上述方法。

笔记2:

在搜索其他内容时,我在AskUbuntu上遇到了与您的问题相关的其他两个问题。

  1. 安装Ubuntu 11后Windows 7无法启动
  2. 安装Ubuntu后Windows 7无法启动

我不确定这些问题提供了多少帮助。 第二个问题的答案是使用命令bootrec /fixboot来恢复Windows分区的VBR。 我对该问题的理解是使用bootrec /fixboot命令解决了这个问题。

但第二个问题坚持认为bootrec /fixboot无法解决问题。

(打败那些可能会发生什么的人。)

 menuentry "Windows 7" { insmod ntfs set root=(hd0,1) drivemap -s (hd0) ($root) ntldr /bootmgr #or chainloader +1 } 

如果在除(hd0,1)之外的分区上安装Windows,则需要使用drivemap命令引导至Windows。 Chainloader +1或ntldr / bootmgr都可用于启动Windows 7。

你做的是你修改了第一个分区的VBR; 从安装CD启动时,可以通过在cmd中的Windows恢复模式下执行这些命令来恢复它:

 bootrec.exe /FixMbr bootrec.exe /FixBoot bootrec.exe /RebuildBcd 

我真的不知道“(UN)启动”你试图通过使用Windows修复盘来修复你的Windows(选择Command Prompt来运行bootsect.exe实用程序.Bootsect位于启动文件夹内,所以将目录更改为如果您最初在C:分区中安装了Windows 7,则运行bootsect /nt60 C:\ (不带引号)。或者,您可以运行“bootsect / nt60 SYS”或“bootsect / nt60 ALL”)

然后重新安装GRUB。

GRUB安装在Windows分区引导扇区(PBR)中,因为您的BootInfo显示:

 sda1: __________________________________________________________________________ File system: ntfs Boot sector type: Grub2 (v1.99) Boot sector info: Grub2 (v1.99) is installed in the boot sector of sda1 and looks at sector 44090872 of the same hard drive for core.img. core.img is at this location and looks for (,msdos2)/boot/grub on this drive. No errors found in the Boot Parameter Block. Operating System: Windows 7 

这可以防止Windows启动。

这里很好地描述了解决方案: http : //ubuntuforums.org/showpost.php?p = 11693662&posttcount = 1

我有同样的问题,并希望确认对我有用的解决方案,希望它能帮助其他人……

我编辑了grub.cfg来反映这里的变化:

 menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 1EA0019AA0017A13 ntldr ($root)/bootmgr } 

也就是说,我补充说……

insmod ntldr

并将最后一行改为……

ntldr($ root)/ bootmgr

我将很快尝试恢复VBR并报告结果如何。

解决了我的Windows 10启动问题….

 menuentry "Windows 10 (loader) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 1EA0019AA0017A13 ntldr ($root)/bootmgr } 

hexadec.code可能不同