在我的电脑上重新安装 Windows 7 后,我在启动时收到以下错误
bootmgr error
我只有拔下 Linux 硬盘才能启动 Windows,并且只有按下打开EscBIOS 并选择 Linux 硬盘才能启动 Linux。
我尝试使用
update grub-install
但这似乎没什么用。如何让 grub 恢复到原来的样子,让两个操作系统都能从 grub 菜单启动?
以下是我的 sudo update-grub 命令:
$ sudo update-grub
[sudo] password for gin:
Generating grub.cfg ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-3.8.0-39-generic
Found initrd image: /boot/initrd.img-3.8.0-39-generic
Found linux image: /boot/vmlinuz-3.8.0-37-generic
Found initrd image: /boot/initrd.img-3.8.0-37-generic
Found linux image: /boot/vmlinuz-3.8.0-36-generic
Found initrd image: /boot/initrd.img-3.8.0-36-generic
Found linux image: /boot/vmlinuz-3.8.0-35-generic
Found initrd image: /boot/initrd.img-3.8.0-35-generic
Found linux image: /boot/vmlinuz-3.8.0-34-generic
Found initrd image: /boot/initrd.img-3.8.0-34-generic
Found linux image: /boot/vmlinuz-3.8.0-29-generic
Found initrd image: /boot/initrd.img-3.8.0-29-generic
Found memtest86+ image: /boot/memtest86+.bin
done
下面是我的 fdisk 命令
$ sudo fdisk -l
[sudo] password for gin:
Disk /dev/sda: 120.0 GB, 120000000000 bytes
255 heads, 63 sectors/track, 14589 cylinders, total 234375000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000764a1
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 226250751 113124352 83 Linux
/dev/sda2 226252798 234373119 4060161 5 Extended
/dev/sda5 226252800 234373119 4060160 82 Linux swap / Solaris
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
256 heads, 63 sectors/track, 121126 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x8d19c4c4
Device Boot Start End Blocks Id System
/dev/sdb1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
Disk /dev/sdg: 4009 MB, 4009754624 bytes
145 heads, 48 sectors/track, 1125 cylinders, total 7831552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004e24a
Device Boot Start End Blocks Id System
/dev/sdg1 * 48 7831551 3915752 7 HPFS/NTFS/exFAT
Disk /dev/mapper/cryptswap1: 4157 MB, 4157603840 bytes
255 heads, 63 sectors/track, 505 cylinders, total 8120320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3a931
Disk /dev/mapper/cryptswap1 doesn't contain a valid partition table
我第一次尝试我该如何修复 grub?(安装 Windows 后如何恢复 Ubuntu?)
$ sudo mount /dev/sda /mnt
mount: /dev/sda already mounted or /mnt busy
gin@ger:~$ for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
mount: mount point /mnt/sys does not exist
mount: mount point /mnt/proc does not exist
mount: mount point /mnt/run does not exist
mount: mount point /mnt/dev does not exist
gin@ger:~$ sudo chroot /mnt
chroot: failed to run command `/bin/bash': No such file or directory
以下是我的启动顺序:
UEFI BOOT SOURCES
WINDOWS BOOT MANAGER
LEGACY BOOT SOURCES
HARD DRIVE
SATO0
SATO1
NETWORK CONTROLLER (REALTEK PXE B07 D00)
答案1
- 不要拔掉电源插头安装了Windows系统的硬盘,或者是安装了ubuntu的硬盘。
- 更改 bios 中的硬盘顺序,将安装 ubuntu 的硬盘设置在列表顶部,保持 Ubuntu 可以默认启动。
- 启动并登录 Ubuntu
跑步更新 grub以 root 身份进入终端。您将在终端中找到一些内容,例如:
“在 /dev/sdxX 上找到 Windows 7(加载程序)”
成功!
- 您可以通过编辑来更改启动顺序
/etc/default/grub
。将其更改GRUB_DEFAULT=0
为您想要的任何内容。(0:表示 grub 菜单中的第一项;1:表示 grub 菜单中的第二项。您可以在启动系统时按“shift”或向下箭头键找到 grub 菜单,或者/boot/grub/grub.cfg
在 ubuntu 中检查)
祝你好运!
答案2
将你的外部硬盘启动到 Ubuntu,挂载你的 Windows 7 分区,然后尝试在终端中运行此命令
sudo 更新 grub
为了安装,您无需使用终端,只需在 Nautilus 中打开 Windows 7 分区即可。