Reinstall GRUB bootloader after windos wipes it out

Discussion in 'Linux & BSD' started by abhishek_a01, May 7, 2008.

  1. abhishek_a01

    abhishek_a01 OSNN Addict

    Messages:
    89
    If you run a dual-boot system with Linux and Windows, this has happened to you. You had to do your monthly reinstall of Windows, and now you don't see the linux bootloader anymore, so you can't boot into Ubuntu or whatever flavor of linux you prefer.
    Here's the quick and easy way to re-enable Grub.
    1) Boot off the LiveCD
    2) 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. Also note that hd0,0 implies the first hard drive and the first partition on that drive, which is where you probably installed grub to during installation. If not, then adjust accordingly.

    sudo grub
    > root (hd0,0)
    > setup (hd0)
    > exit

    Reboot (removing the livecd), and your boot menu should be back.

    Only read below if Windows is now missing from the boot menu
    If you installed Ubuntu before you installed Windows, then Ubuntu will not have anything in the grub configuration for Windows. This is where you'll have to do a bit of manual editing to the grub boot menu file.
    If you open the file /boot/grub/menu.lst with the following command:
    sudo gedit /boot/grub/menu.lst
    You'll see a sample section for Windows, which you'll want to uncomment and add to the boot menu list in whatever position you want it in. (uncomment by removing the #'s)

    # title Windows 95/98/NT/2000
    # root (hd0,0)
    # makeactive
    # chainloader +1

    Note that you should also verify that hd0,0 is the correct location for Windows. If you had installed Windows on the 4th partition on the drive, then you should change it to (hd0,3)
     
  2. Dark Atheist

    Dark Atheist Moderator Political User Folding Team

    Messages:
    6,376
    Location:
    In The Void
    why you should always load windows first
     
  3. abhishek_a01

    abhishek_a01 OSNN Addict

    Messages:
    89
    i guess because linux people think person will shift from windows to linux not from linux to window. So if anyone first installed linux then there is lot more chance he won't go for window. But this is vice versa if person install window first :)
     
  4. falconguard

    falconguard Carbon based lifeform Political User Folding Team

    Messages:
    3,406
    Location:
    SoCal
    Monthly reinstall of windows? Whatever for? Both are stable enough for me that I have not reinstalled anything.

    What if you are using the LiLo bootloader?
     
  5. KenJackson

    KenJackson Linux Guy Political User

    Messages:
    11
    Location:
    Maryland, USA
    I thought Carpo was making a statement or a lament, but you seem to be answering him like it was a question.

    Windows is almost always installed first anyway, because almost all PCs are sold with Windows installed. And the few people that buy a PC without Windows are usually savvy enough to want something better. :p

    But if you are installing everything from scratch, there is a very good reason to install Windows first. Windows assumes it owns the machine. It is not designed to play well with competitors. So for best results, install Windows first and then install any other OS you want, which will surely behave like a gentleman and not try to take over the MBR unless you ask it to.
     
  6. abhishek_a01

    abhishek_a01 OSNN Addict

    Messages:
    89
    oh i thought it was question. nways thanks...
     
  7. Dark Atheist

    Dark Atheist Moderator Political User Folding Team

    Messages:
    6,376
    Location:
    In The Void
    just type liloconfig and remake it, and yes the above reply was a statement and not a question, because if it was a question it would have had a ? at the end of it :p
     
  8. vern

    vern Dominus Political User Folding Team

    Messages:
    1,571
    Location:
    Minnesota, USA
    Useful info. I've done this while already dual-booting XP/Linux then installing Vista.
     
  9. Mainframeguy

    Mainframeguy Debiant by way of Ubuntu Folding Team

    Messages:
    3,763
    Location:
    London, UK
    Having just had the unfortunate experience of installing XP and then UBUNTU intrepid Ibex twice each I can confirm that the Ibex is no "gentleman"! So the moral of the story is always expect the unexpected - the partitioner in Ibex has issues and royally screwed me (partly my fault, should have planned ahead and done a little googling research, but easy to be wise after the event!).

    Always expect the unexpected! :D