How can I restore GRUB without a live CD?

9

2

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?

gkanwar

Posted 2010-08-28T12:19:20.453

Reputation: 291

I also should mention that after some working with the grub-rescue> prompt, I determined that grub was indeed on the partition that I deleted. If I could just boot into the other Ubuntu partition that I have to reinstall it, this would be great. – gkanwar – 2010-08-28T13:01:25.063

Answers

9

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!

gkanwar

Posted 2010-08-28T12:19:20.453

Reputation: 291

just for others who might look at this answer, a short method is to input these commands in order. the first references where your grub files are located; 1.set prefix=(hdX,Y)/grub 2. insmod normal 3. normal – Douglas Hosea – 2017-07-26T10:49:10.143

Great, nice you could fix it! And the documentation on the wiki improved greatly since I last saw it, which is also great (could be useful for people with other distros too). – JanC – 2010-08-30T14:54:32.987

in my case it was insmod /boot/grub/i386-pc/linux.mod – Artur Klesun – 2019-11-11T17:01:04.307

3

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).

JanC

Posted 2010-08-28T12:19:20.453

Reputation: 1 125

No, I did not, but I have no idea how to boot from the rescue prompt. If I could do that, it'd be ideal. – gkanwar – 2010-08-28T12:52:39.217

Well, you were right. I just needed to find the commands to boot from the rescue prompt. The details are in my answer. Thanks! – gkanwar – 2010-08-29T17:45:51.867

+1, since this helped address the immediate problem. – nik – 2010-08-29T18:06:16.373

2

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.

nik

Posted 2010-08-28T12:19:20.453

Reputation: 50 788

This probably would have worked, but the rescue prompt worked out easier in the end in my case. Thanks anyway! – gkanwar – 2010-08-29T17:46:15.267