I have a Laptop dual booting Windows 7 and Ubuntu, however it doesn't boot into Windows anymore. I'm pretty sure the boot sector of the windows partition (the beginning of the partition, not the MBR!) is borked. How do I restore it from Linux?
(The laptop doesn't have a DVD drive, and I'd rather not make a Windows installation USB because it took me several tries last time. Also, the windows installer will overwrite not only the boot sector, but also the MBR, killing GRUB, so I'd have to fix Ubuntu afterwards.)
Details:
The partition layout is as follows:
Device Boot Start End Blocks Id System
/dev/sda1 54 151129367 75564657 5 Extended
/dev/sda2 151129368 302247179 75558906 7 HPFS/NTFS/exFAT
/dev/sda3 * 302247180 312497351 5125086 c W95 FAT32 (LBA)
/dev/sda4 312497352 312578243 40446 ef EFI (FAT-12/16/32)
/dev/sda5 108 4194827 2097360 82 Linux swap / Solaris
/dev/sda6 4194882 151129367 73467243 83 Linux
sda1 is an extended partition containing Linux (sda4, sda5 and sda6). sda3 is the recovery partition (a modified Windows XP, it seems). sda2 is the Windows 7 partition (NTFS). I can mount it from Linux, and everything seems to be there.
Grub can't boot into Windows 7. The boot menu contains an entry called “Windows”
(note the funny quotation marks), that tries to boot (hd0,1)
=sda1, of course unsuccessfully. I can manually boot sda3, but there's not point to that.
When I try to boot sda2 (Windows 7), I get "NTLDR is missing". This is weird, because Windows 7 doesn't use NTLDR, but BOOTMGR. I don't remember how this got borked up (it happened some time ago), but I guess some recovery tool I tried installed the wrong bootsector on that partition. This is what the beginning of the partition looks like:
$ sudo dd if=/dev/sda2 bs=512 count=1 | hd
00000000 eb 52 90 4e 54 46 53 20 20 20 20 00 02 08 00 00 |.R.NTFS .....|
00000010 00 00 00 00 00 f8 00 00 36 00 d6 00 18 0d 02 09 |........6.......|
00000020 00 00 00 00 80 00 80 00 f3 df 01 09 00 00 00 00 |................|
[...]
00000170 b4 01 8b f0 ac 3c 00 74 09 b4 0e bb 07 00 cd 10 |.....<.t........|
00000180 eb f2 c3 0d 0a 41 20 64 69 73 6b 20 72 65 61 64 |.....A disk read|
00000190 20 65 72 72 6f 72 20 6f 63 63 75 72 72 65 64 00 | error occurred.|
000001a0 0d 0a 4e 54 4c 44 52 20 69 73 20 6d 69 73 73 69 |..NTLDR is missi|
000001b0 6e 67 00 0d 0a 4e 54 4c 44 52 20 69 73 20 63 6f |ng...NTLDR is co|
[...]
I have to say I tried update-grub and boot-repair to no avail. Grub is installed and working correctly, what's wrong is the Windows loader that is chainloaded by Grub. What I need is something like bootsect /nt60 C:
for Linux, or any way to get a clean copy of the bootloader on to my partition. Any ideas?
Best Answer
Funny how I've been trying this for so long, and just after posting here have found a solution. I've stumbled upon a Windows 7 Recovery USB stick.
Boot from the stick. I had to do a cold boot with the stick in an usb port, otherwise the PC wouldn't recognize it. Then I had to tell grub to boot from
(hd1)
.The recovery disk might offer to repair stuff, but that didn't work for me.
Start a command prompt and do the following:
Copy the boot loader over. X: is the recovery drive, C: is the partition on the laptop.
If that doesn't work, you might have to remove bootmgr first:
Properly install the boot loader. From
X:\windows\system32
call:The second line is for good measure, not sure it's neccessary. Don't do
bootrect /fixmbr
, as this will overwrite GRUB.It could work now, but if it doesn't, you have to recreate the boot menu data (the BCD). From the recovery prompt:
Now reboot. Tell grub to boot from
(hd0,2)
or whatever the windows partition is, and it should work. After agrub-update
, Windows 7 should be properly in the menu again.Resources: