Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Original title: How can i solve (un)booting windows 7 on the same partition with grub?

I've been researching for 2/3 days about this problem and I have came up empty.

Basically, partition 1 is Windows 7 and partition 2 is Ubuntu 12.04. I told Ubuntu to install into partition 2 and to install grub on partition 1 and that works fine. But the problem now is that I can't boot to Windows 7. It just returns to the grub menu after I select it.

From what I have researched, if I can edit grub to boot Windows 7 "mbr" or the bootloader \windows\system32\winload.exe (without using windows 7 repair disk), my problem will be solved. Is this even possible?


The url from Boot-Repair-Info is http://paste.ubuntu.com/981952/


Output from the command 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"
share|improve this question
add comment

5 Answers

up vote 5 down vote accepted

Could you create a Bootinfo Summary report using the boot-repair tool as described below and then post the link to the report?

I know you have already provided some details about your boot configuration. However, the report I am asking for contains more detailed information and might give us a better understanding of why you are unable to boot Windows using GRUB.

How to use boot-repair to provide a "Bootinfo Summary"


Since your can still boot Ubuntu, you can install and run the Boot-Repair tool using the apt-get command and then use it to Create a Bootinfo summary.

Run the commands below in a terminal window to install the boot-repair tool.

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair
  1. After that completes, enter the command boot-repair to start the tool.
  2. After a slight delay, boot-repair will ask if you want to download its newest version. Since you just installed the newest version, answer No.
  3. If boot-repair asks to install the pastebinit package, respond with Yes.
  4. The tool will now scan your system and (eventually) display the window shown in the image below. Click on the Create a Bootinfo summary box/button. This will collect information about your system's boot configuration, but will not make any changes.


    Initial Boot-Repair Window

  5. When the bootinfo summary has been created, boot-repair will display a message containing a URL which should look like this: http://paste.ubuntu.com/123456/.

    Please update/edit your question and add this URL. The information in the pastebin this link points to will (I hope) help us diagnose the problem.

I think over-writing the Windows partition's VBR caused this problem.

My understanding is that there are several steps to starting an operating system. In your case I think something like the steps below happen.

  1. The BIOS on your computer attempts to run the code in the first sector of the hard drive. This first sector is usually referred to as the MBR (Master Boot Record).
  2. In addition to the MBR, every partition can also have a boot record. It is often referred to as the Volume Boot Record or VBR. The MBR on your hard drive transfers control to the VBR of partition 1, your Windows partition.
  3. Windows expects a partition's VBR to take the next step towards booting an operating system such as Windows 7. So Windows would have originally installed a VBR which would transfer control to the Windows bootmgr program in your Windows partition.

    However, when you instructed the Ubuntu install program to install GRUB into the Windows partition, GRUB appears to have replaced the Windows VBR with its own. This GRUB VBR displays the GRUB boot menu.
  4. The instructions GRUB currently uses to boot Windows are essentially to locate the VBR in the Windows partition and transfer control to it. The VBR in the Windows partition is GRUB's VBR. Transferring control to it just (re)displays the GRUB boot menu.

Unfortunately, I am not sure yet what would be the best way to fix this. We want to be careful that we do not break GRUB and make it impossible to boot anything on your computer when we attempt to fix the problem booting Windows.

Below is a copy of some of the information from your Bootinfo Summary for reference. My comments above are based on this information.

============================= 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

A possible work-around to boot Windows 7

Below is a suggestion for editing your GRUB boot commands which may allow you to boot Windows 7. I am not sure this will work, but it seems worth trying.

Currently your grub.cfg uses the GRUB boot commands below to boot 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
}

I am suggesting you try changing this and use these commands instead.

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
}

Here are the steps to do this.

  1. Boot your system to the GRUB menu.
  2. Select (highlight) the GRUB boot menu entry Windows 7 (loader) (on /dev/sda1).
  3. Press e to edit the GRUB boot commands for Windows 7.
  4. Make two changes to this list of commands as illustrated in the menuentry above.
    • Add the command insmod ntldr
    • Change the command
      chainloader +1
      to
      ntldr ($root)/bootmgr
  5. Press either Ctrl+X or F10 to boot using these edited commands.

Note 1:

If the above work-around succeeds in loading the Windows 7 boot menu, then you could make it semi-persistent by

  1. Using sudo to edit the file /etc/grub.d/40_custom and add the second, modified menuentry shown above. (If you do this, I'd also suggest you change the title of this "custom" entry.)
  2. Run the command sudo update-grub to update /boot/grub/grub.cfg to include your customized entry. (It will be on the bottom of the GRUB menu when you boot.)

I would view the suggestion above as only a partly-baked solution. A better solutions is to restore the Windows VBR to the Windows partition without also destroying the ability of GRUB to boot.

I think ... but am not 100% sure ... that the Windows recovery command bootsect can be used to do this. If you want to risk it, one possible way to do this is outlined below.

  • When booting Windows, press F8 to bring up the Advanced Boot Options menu.
  • Select the Repair Your Computer entry.
  • Walk through the next windows until you reach System Recovery Options.
  • Select Command Prompt
  • Run the command bootsect /nt60 C:

But you might also want to wait a bit and see what other answers you get to your question before you take the risk of trying the above.

Note 2:

While searching for other things, I ran across two other questions on AskUbuntu which are related to your problem.

  1. Windows 7 won't boot after installing Ubuntu 11
  2. Windows 7 doesn't boot after Ubuntu install

I'm not sure how much help these questions provide. The answer to the second question was to use the command bootrec /fixboot to restore the VBR for the Windows partition. My understanding from that question was that using the bootrec /fixboot command solved the problem.

But the second question insists that bootrec /fixboot did not solve the problem.

(Beats the heck out of me as to what might be going on there.)

share|improve this answer
    
Thank you for your reply. I alright have it, lucky, but if other people didnt know about it, they do now. The url from Boot-Repair-Info is http://paste.ubuntu.com/981952/ –  Sim May 11 '12 at 16:35
1  
I think your problem was caused by installing GRUB into your Windows partition. See the update to my answer. –  irrational John May 11 '12 at 17:29
    
So what do you think I can do? Should I use bootrec and then reinstall grub? or is there another way? –  Sim May 11 '12 at 18:26
    
You could repair the Windows boot as usual, when that's done Windows will automatically boot without even asking you (Windows does not recognize Linux). When that's fixed, you can boot Linux from a USB and run GRUB again, this time don't touch the Windows partition ;) –  bigbadonk420 May 11 '12 at 18:48
    
Added a suggestion for a possible temporary workaround to my answer. –  irrational John May 11 '12 at 18:53
show 4 more comments

I don't really know about "(UN)booting)" you shoud try to fix your Windows by using Windows Repair disk (choose Command Prompt to run the bootsect.exe utility. Bootsect is located inside the boot folder so change your directory to boot. Now run bootsect /nt60 C:\ (without quotes) if you had Windows 7 initially installed in the C: partition. Alternatively, you can run "bootsect /nt60 SYS" or "bootsect /nt60 ALL")

And then re-install GRUB.

share|improve this answer
    
Thank you for the reply. What I meant was the grub boots but not windows after I select it. Researching, people say that to repair boot for mbr, we should use "bootrec.exe /fixboot" then "bootrec.exe /fixmbr". Is your method the same as bootrec or different? –  Sim May 11 '12 at 8:07
    
In my experience,after Ubuntu installation as dual boot,it will be better to run Windows on reboot and do the repair by itself, then come back to Ubuntu.I followed this method everytime and found successful. –  beeju May 11 '12 at 16:14
    
True. For windows I use EasyBCD –  Sim May 11 '12 at 16:29
add comment

GRUB is installed in your Windows partition boot sector (PBR), as your BootInfo shows:

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

This prevents Windows from booting.

Solution is described nicely here: http://ubuntuforums.org/showpost.php?p=11693662&postcount=1

share|improve this answer
add comment

I had this same issue and would like to confirm the solution that worked for me in hopes that it helps others...

I edited grub.cfg to reflect the changes here:

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
}

That is, I added...

insmod ntldr

and changed the last line to...

ntldr ($root)/bootmgr

I'm going to attempt to restore the VBR shortly and will report back how it turns out.

share|improve this answer
add comment
menuentry "Windows 7" 
{
insmod ntfs
set root=(hd0,1)
drivemap -s (hd0) ($root)
ntldr /bootmgr
#or chainloader +1
}

If you installed Windows on partition other than (hd0,1) you need to use drivemap command to boot to Windows. Chainloader +1 or ntldr /bootmgr both can be used to boot Windows 7.

What you did is you modified MBR of 1st partition, you may restore that by executing these commands in windows recovery mode in cmd when you boot from installation CD :

bootrec.exe /FixMbr  

bootrec.exe /FixBoot  

bootrec.exe /RebuildBcd
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.