Fixed Windows - But Now Grub is Gone?

Page 1 of 3 123 LastLast

  1. Posts : 2,736
    ...
       #1

    Fixed Windows - But Now Grub is Gone?


    Windows Seven Forums addresses topics related to Windows not Linux. However, as a courtesy for those Windows 7 users who may also dual boot with a Linux OS, this thread will briefly show how to easily restore the Linux Grub boot loader after a Windows repair has overwritten Grub.

    I will use the Ubuntu 9.10 Install CD to make the repairs. It does not matter what Linux distribution you are dual booting, Grub is a Linux based program and is much the same for all. You can also download and burn the Ubuntu CD and use it as described without altering your Linux disrtibution.

    Here's how:

    Boot to the Ubuntu CD (or the Linux Live CD of your choice)
    You must first select a language:

    Fixed Windows - But Now Grub is Gone?-grub_fix_01.png

    Then select "Try Ubuntu without any change to your computer"

    Fixed Windows - But Now Grub is Gone?-grub_fix_02.png

    The Ubuntu Live CD will load and the Ubuntu desktop will appear.
    Open a "Terminal"

    Fixed Windows - But Now Grub is Gone?-grub_fix_03.png

    In the terminal type: sudo fdisk -l (that is a small L for list)

    You must find the /dev/sda number of the partition for your Linux OS
    In this picture it is /dev/sda7

    Next type: sudo mount /dev/sda7 /mnt (use the Device ID for your Linux)

    Then type: sudo grub-install --root-directory=/mnt/ /dev/sda (with no number)

    Fixed Windows - But Now Grub is Gone?-grub_fix_04.png

    When successful, type: exit

    Fixed Windows - But Now Grub is Gone?-grub_fix_05.png

    Restart and you should have a restored Grub menu to boot from.

    Fixed Windows - But Now Grub is Gone?-grub_fix_06.png

    As a final step, if necessary, boot into Ubuntu and open the "Terminal".
    Type: sudo update-grub

    Fixed Windows - But Now Grub is Gone?-grub_fix_07.png

    The Grub menu will refresh adding any missing Operating Systems.
      My Computer


  2. Posts : 8,476
    Windows® 8 Pro (64-bit)
       #2

    Awesome work mate. :)
      My Computer


  3. Posts : 2,736
    ...
    Thread Starter
       #3

    Dinesh said:
    Awesome work mate. :)
    Thank you, Dinesh.
      My Computer


  4. Posts : 9
    Windows 7
       #4

    Thanks


    Thanks a lot Dinesh, you've saved me untold hours of frustration. Now I can get things done! I was afraid it was a hardware issue. But as your post suggested, perhaps grub was overwritten due to a Windows repair.

    Now I'm curious how this happens. First, I did not perform a Windows repair directly before this problem started happening. Second, everything was working fine for 2-3 days; Ubuntu 10.04 and Windows 7 were both installed with no problems. Nothing in my setup, to my knowledge, was altered to effect this change of GRUB.
      My Computer


  5. Posts : 8,476
    Windows® 8 Pro (64-bit)
       #5

    dajohnson89 said:
    Thanks a lot Dinesh, you've saved me untold hours of frustration. Now I can get things done! I was afraid it was a hardware issue. But as your post suggested, perhaps grub was overwritten due to a Windows repair.

    Now I'm curious how this happens. First, I did not perform a Windows repair directly before this problem started happening. Second, everything was working fine for 2-3 days; Ubuntu 10.04 and Windows 7 were both installed with no problems. Nothing in my setup, to my knowledge, was altered to effect this change of GRUB.
    Hi, you should thank isuuee for this, not me.
      My Computer


  6. wee
    Posts : 101
    XP/W7/Lucid/Arch
       #6

    Actually it does matter which version of Ubuntu your using and which version of grub your installing. If you have grub-legacy which is grub .97 which was part of the Ubuntu distributions until Karmic koala where grub2 became the default. As far as I know if you have grub legacy installed and the MBR is overwritten, the grub files in Ubuntu are not. So you have to use a Live CD with grub legacy to set it back up. Consequently if your running Grub2 you would use the appropriate cd karmic or lucid to follow this tutorial.

    The instructions are correct for reinstalling grub2. I could be wrong here but the fact that the reinstall method only rewrites the MBR is the key it doesn't rewrite the grub files in Ubuntu.

    Here is a grub2 wiki for help. https://help.ubuntu.com/community/Grub2#Upgrading At the Ubuntu forums we run into people that have installed both grub versions this way it is a mess but can be fixed. We also see people who have loaded grub into the MS bootloader bcd in the partion this can be fixed as well generaly with using testdisk. SourceForge.net: Boot Problems:Boot Sector - bootinfoscript

    This problem can also be fixed with running the following commands from a W7 install disk.
    You will need to boot with your Vista/Windows 7 installation disk. Hit Enter at the language selection prompt then hit "R" to get to the repair section. You can then select the automatic boot repair tool, but it often will not do any good. Then select the command prompt (console) and type in the following commands:
    BootRec.exe /fixmbr skip this if you want to retain grub.
    chkdsk /r
    BootRec.exe /FixBoot
    BootRec.exe /ScanOs
    BootRec.exe /RebuildBcd


    I suspect most people dual booting are using the latest release of Ubuntu or one with grub2 but if not this method of installing grub2 will leave you in a mess, if you have grub legacy.

    The last thing really needed when messing with the MBR and figuring out what may have gone wrong, and finding out the version of grub and where it is installed is this boot script. This script would also help a sole MS install as well.
    http://bootinfoscript.sourceforge.net/

    Additionally if your running Jaunty and update from grub legacy to grub2 you have to do a edit for it to work.
    http://www.situsinformasiinternet.co...unty-9-04.html

    The good thing is though that there are people on this forum and the Ubuntu forums that can help you if you have problems, the main point is don't install grub2 as a reload when you have grub legacy.

      My Computer


  7. Posts : 2,736
    ...
    Thread Starter
       #7

    wee;

    Thank you for taking time to post this extra detailed information. However, I remind you that as I stated, this thread was in no way intended to be the complete authority on Grub, Ubuntu, or Linux distributions. You were kind enough to post to links of web sites that already serve that purpose.

    You make a valid point that one should not attempt to use the instructions provided to reinstall "Legacy Grub". As stated the example provided was from Ubuntu 9.10 which installs Grub2. As "Legacy Grub" is no longer being maintained or supported by anyone, who is going to install a current Linux distribution, including Grub2, then uninstall Grub2 and replace it with "Legacy Grub"? In my opinion, anyone competent enough, or determined enough to do that does not need this thread to repair Grub.

    I am sure you will agree with me that it is accurate to say that Grub2 is the same across all Linux distributions that include Grub2? And that this Ubuntu 9.10 CD can be used to reinstall Grub2 even if the installed Linux distribution is not Ubuntu?

    Thank you also for posting the "bootrec.exe" commands. Here is a Microsoft link to more info on those commands: How to use the Bootrec.exe tool in the Windows Recovery Environment to troubleshoot and repair startup issues in Windows

    However, if restoring the MBR boot code to Windows is the goal, an easier way may be the "bootsect.exe" command as described here: MBR - Restore Windows 7 Master Boot Record

    Cheers!
    Robert
      My Computer


  8. wee
    Posts : 101
    XP/W7/Lucid/Arch
       #8

    I certainly wasn't trying to usurp your instructions they are detailed and correct it is just the different grubs can make a difference.

    I have never been able to get the auto repair to work myself when grub has been installed in to the MBR, this doesn't mean it doesn't work though. I recognize that the auto repair runs basically the same commands, or so I have been told, but the chkdsk /r command isn't run, I think, which is actually a good one to run this will clean up stuff.

    Actually when I have re-installed the MS bootloader to the MBR with a dual boot of W7 and Lucid the bootrec.exe /fixmbr and fixboot alone have worked with no problems, and the commands you posted to reload grub worked to restore grub2.
    But I haven't borked my set up by having the bootloaders in the wrong places just reloading them for test purposes.

    What happens sometimes is that without running the bootscript it is a guessing game as to where grub has been installed and so this is a key component to getting to the heart of the matter so to speak.

    There is a bug in the Ubuntu install as well, that is a gui that comes up asking where grub goes, and if your not sure install it in a partition or all, this is causing some for people who are not sure about grub to install, it in the bcd of Windows, and partitions in general. The testdisk will fix this, but I am more a fan of just manually restoring the bcd boot loader with the full set of commands then restore grub2 with the commands you provide.

    Hey we are all here to help each other so it is all good.
      My Computer


  9. Posts : 2,736
    ...
    Thread Starter
       #9

    For testing purposes, I had 5 OSs including Ubuntu 9.10 installed using VirtualBox. I was able to 'bork' and repair successfully several times using the tools mentioned. However, as there are almost always other ways to accomplish the same things, I appreciate your additional info. IMHO, more info is always better than less!

    Cheers!
    Robert
      My Computer


  10. Posts : 9
    Windows 7
       #10

    Windows 7 hibernation and Grub2 loss


    OK, first I ought to correct the thanks. Thanks to isuuee, not Dinesh.

    Second, the method of re-installing GRUB with the Ubuntu (10.04) Live CD is NOT permanent. Just now, my boot sequence got caught up in an infinite loop; never reaching GRUB. Imagine my frustration; it has only been two days since I encountered the problem, searched for a solution and implemented it!

    I conjecture that Windows hibernate is a culprit, at least in my case. The first time, and this most recent time, that GRUB was messed up, I had Windows 7 loaded, and my notebook slipped into hibernate mode after several hours of inactivity. Fortunately, one can just do without hibernation. In my case, I just repeated the re-installation of GRUB, and everything works fine. I should add that previous to the occurrence of the problem, shutting down and restarting normally under either OS incurred no problems. It was only after hibernation.
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:39.
Find Us