How can I restore GRUB without a live CD?

I realize that this is a duplicate of a question asked before, but in that question the asker managed to find his live CD and no real answer appeared, thus I am re-asking it.

I managed to screw up my GRUB by deleting two linux partitions on my hard drive from windows. After this, GRUB gives the error "partition not found", and gives me the grub-rescue> prompt. The only command I have found to work in this is 'ls', which spits out my partitions. I would use the live CD fix, but I am in India, and all my live CDs are back home in the US... What I've got is an internet connection, a 4GB flash drive with Flow OS installed (which I am currently using but can wipe if need be), and a working laptop that I can borrow. What should I do?


Solution 1:

Well, I managed to have this one fixed about 20 minutes after I posted, but I forgot to update this until today. Here's the details:

I managed to boot using the grub rescue prompt with the help of the Ubuntu grub2 reference using these commands:

  1. ls
  2. set prefix=(hdX,Y)/boot/grub
  3. set root=(hdX,Y)
  4. set
  5. ls /boot
  6. insmod /boot/grub/linux.mod
  7. linux /vmlinuz root=/dev/sdXY ro
  8. initrd /initrd.img
  9. boot

This got me into my Ubuntu partition, at which point I was able to do "grub-install /dev/sda". And that's it! I can't believe it took me about an hour before I finally found this solution. Hope it helps someone else!

Solution 2:

Did you delete the partitions that contained the grub binaries & config? If not, you can probably still boot from the rescue prompt...

Also, you can use Unetbootin to put the Ubuntu live CD on an USB stick (this can be done from almost any linux or Windows system).

Solution 3:

You can get the SuperGrubDisk and maybe create a Live USB with Unetbootin on some handy Windows machine.

This Boot Problems Wiki page on SuperGrubDisk site is also a good reference to keep handy.
Of particular interest may be How to fix GRUB.