Saturday, August 14, 2010

Recovering Boot Loader

Hi everyone!! I am back with my second blog… This time it’s regarding recovering boot loader. I have tried to be short & precise....

It may happen that if you have windows installed on your system and you install Linux natively on it, your Windows boot loader gets lost. Your whole data will be there, just that you need to restore the boot loader… This is how you can do it:
  • Insert your Windows installation CD (I tried with Windows 7).
  • When you get to the second screen (after you choose your language) go to ‘Repair your computer’.
  • Go to command prompt and type this in without the quotes (") :
    "bootrec /fixmbr”
  • Press enter.
  • Type this in without the quotes (") :
    "bootrec /fixboot"
  • Press enter
  • Restart

In case you install Windows after Linux (in my case, Ubuntu version), Linux boot loader (here, Grub) wont exist anymore. Here’s the quick and easy way to re-enable Grub:

  • Boot off the Live CD
  • Open a Terminal and type in the following commands, noting that the first command will put you into the grub “prompt”, and the next 3 commands will be executed there.

    sudo grub

    find /boot/grub/stage1
    root (hd?,#)
    setup (hd?)
    quit
    (where hd?,# is returned from find command)
  • Reboot (removing the CD)

There are high chances that when you restore windows boot loader, the MBR would be rewritten (since windows doesn't want to recognize any other OS!). So its preferrable that windows should be installed first and then linux.

Queries & comments are always welcome!! :)

12 comments:

  1. Just a question, Why on earth would you even want to restore the Windows Bootloader (NTLDR) instead of Grub?
    Not only does it not detect any other OS, Grub is configurable, and much more stable! Plus, Grub can be rewritten and upgraded, Windows NTLDR is basically useless unless you are only running a single OS natively installed.

    ReplyDelete
  2. nice work nikita, really usefull blog

    ReplyDelete
  3. Nice work on the post.....though I'd just appreciate only the first 1/4th part of it.

    I agree with the information on recovering the windows boot loader. But in some cases, even BootRec.exe /fixmbr works and does not require BootRec.exe /fixboot.
    BTW, I hope you noticed the .exe on BootRec.

    Coming to recovering Grub...
    You have not mentioned which Grub this recovery method is for. Grub Legacy or Grub2.
    Anyways, it won't matter since this method won't work for the Ubuntu 10.04 Live CD since it does not have grub in the CD (apparently!), so "sudo grub" WILL give you the error "sudo: grub: command not found" for the Ubuntu 10.04 Live CD. Though I do agree that this method should work like a charm on other Linux flavours i.e. Fedora(particularly).
    Plus, if you have Ubuntu 10.04(I have to be specific since there is no fail-proof method for all linux versions), then most probably NOTHING would work!!! and you might get your Grub back suddenly!!! The reason for this is still unknown.

    Source: Personal Experience

    ReplyDelete
  4. @purujit: sorry for so late reply.. I couldn't check my blog for few days. As far as your ques is concerned that why would anyone like to recover windows bootloader instead of grub, many would like to do that. At least me... because for someone used to windows, switching over to linux completely is not feasible.

    ReplyDelete
  5. @exotic-pulse: thanks for appreciating the first 1/4th part!!
    I agree that in some cases alone BootRec /fixmbr works and does not require BootRec /fixboot. But you require that in some cases. So no harm in using that I guess...
    Coming on to the '.exe' part, i reloaded my windows 7 boot loader without using '.exe'. It works.
    Thanks for your information on grub recovery. Frankly, I haven't tried this part... Just googled it. So I assume that since you have practical experience, you are right about this method not working for Ubuntu 10.04 Live CD.
    Thanks for sharing your experience! :)

    ReplyDelete
  6. Sorry. I was a bit too harsh in my previous comment. LOL! Uhm... About BootRec.exe, I heard some of my friends say they got an "Element Not Found" error when they gave the command without the extension. Though that may be a one-of-a-kind case. I know that it should work without the extension. Just thought of bringing the anomalies to light... :D

    ReplyDelete
  7. @exotic-pulse: thats ok!! never mind! Thanks :)

    ReplyDelete
  8. I agree, it certainly does seem as if you've just copied and pasted it from certain sources on the internet without trying it out yourself.

    Can you describe what each command does in the method for recovery that you've described?
    Also, can you highlight the differences between the method you've described versus the method we used in the lab? Specifically, I'm interested in knowing which one is better in your opinion and why.

    ReplyDelete