Update destroyed grub

I have Ubuntu 10.04 (Lucid Lynx) installed on my notebook via wubi. Since a recent ubuntu update however my system doesn't work anymore. When I boot I get into grub rescue>. After some internet reading I concluded that I would have to re-install grub (I was forgotten :$ that I installed Ubuntu via wubi, thought I had it standalone..) and used this tutorial. Now I have a command line grub and am confused about what to do.

My directory structure is as follows:

/dev/sda5 (NTFS)  
    /boot
        /grub
            <grubfiles>
    /ubuntu
        /disks
            /boot
                /grub
                    <empty>
        /install
        /winboot
        ...
    ...

Is it logical that /ubuntu/disks/boot/grub/ is empty? I would like to get the bootloader back to being able to choose between windows and linux. Any help appreciated :)

Update My problem is kind of solved by installing a standalone Ubuntu 10.10. Now I got my bootloader back correctly, have to go through 3 bootloader screens now to enter Ubuntu 10.04 though ^^


Solution 1:

At first I answered this question to match Lucasmus' situation where he actually had been able to restore the ability to boot already, and had a working grub from a (non-wubi Ubuntu install) on his MBR. Since most people coming here are probably not in that situation, but just getting the grub rescue shell at boot and can't boot Windows or their Wubi install at all, I've remade the instructions for the normal case. The answer for Lucasmus's question was basically to follow what's now steps 2 through 5 below.

This is unfortunately a known bug in Wubi https://bugs.launchpad.net/bugs/610898. I've submitted a patch to hopefully prevent future users from having Wubi render their drive completely unbootable but until that or another fix is accepted this is what you need to do (in Wubi) to get Windows and Ubuntu booting and prevent this from happening again:

1: Boot from an Ubuntu LiveCD and run sudo software-properties-gtk -e universe && sudo apt-get update && sudo apt-get install mbr && sudo install-mbr /dev/sda.

If you have more than one hard drive you will need to change /dev/sda in that last command to the drive windows is on. But it will always be a drive, never a partition. So /dev/sdb might be appropriate but never /dev/sdb1 (doing the latter could overwrite Window's PBR making it even harder to boot back into windows).

Now you should be able to boot into Windows or your Wubi install like before. If you want to continue using Wubi then follow the next steps to be sure that you don't get into an unbootable situation again.

2: Boot into your Wubi install and run sudo dpkg-reconfigure grub-pc This will bring up some dialogs with questions.

3: For the first question The following Linux command line was extracted from /etc/default/grub or the 'kopt' parameter in GRUB Legacy's menu.lst. Please verify that it is correct, and modify it if necessary. Leave the field at its default (probably blank) and press enter to continue to the next question.

4: For the second question The following string will be used as Linux parameters for the default menu entry but not for the recovery mode. again leave it at the default (probably "quiet splash") and press enter to continue

5: This question ...GRUB install devices: is the important one. Make sure that you uncheck everything but /dev/loop0. You can check/uncheck an entry with the space bar, and change entries with the arrow keys.

If you press enter before unchecking /dev/sda from this list your computer will become unbootable again.

Now you can safely update/upgrade your Wubi install without worrying about your computer becoming unbootable.