REASONS:
- Grub, by default, resides in the Master Boot Record(MBR). When you try to install some other boot loader or try to install/reinstall Windows, the grub information in the MBR will be overwritten. So, Grub might have to be reinstalled.
- When some/any part of partition information is changed, the grub configuration won’t be automatically notified of it and so, the grub configuration will remain as it is. There maybe many cases in which the partition information maybe changed like when you create an extra partition, which is something trivial and may or may not affect the grub boot loader. However, most of the times, changes in the partition information will result in errors when the grub boot loader is loaded. So, the grub configuration has to be updated and the easiest way is to reinstall Grub.
There are many such cases and in these cases, people tend to treat the effect, more than the cause. By this, I mean people tend to usually reinstall Ubuntu or Fedora or whichever GNU/Linux operating system they are using, through which Grub will be automatically reinstalled. But is it necessary? No, Grub can be reinstalled without reinstalling the entire operating system! In fact, Fedora CD/DVD does offer to reinstall Grub if you choose to upgrade your system. However, I have tried to use that option in many of my friends’ computers and it has never worked! I have no idea why it doesn’t work. So I resort to the easiest fool-proof method I know – COMMANDS @ TERMINAL
COMMANDS TO REINSTALL GRUB:
All you need to do is access the terminal using the installation CD/DVD of your GNU/Linux operating system. Ubuntu installation CD is a live CD and so, when it loads, you can run the terminal from there. Fedora installation CD/DVD offers options through which you will have to choose to upgrade the system using commands(rescue mode).
Once you are at the terminal, you will have to access the ‘grub’ shell to change the grub configuration. So, give this command at the terminal:
$ grub
If it says that you don’t have the permission, in which case you will not have logged in as root(as in Ubuntu), give this command at the terminal:
$ sudo grub
You will get the grub-shell prompt:
grub>
Now, you will have to find out in which partition Grub had been installed before, so that you reinstall in that partition only. Give this command at the terminal:
grub> find /boot/grub/stage1
(returns value)
It returns the number of the partition in which Grub i.e your GNU/Linux had been installed.
e.g.,
grub> find /boot/grub/stage1
(hd0,2)
Before reinstalling Grub, you will have to notify the partition that your Grub i.e. GNU/Linux is resided in. So, give this command at the terminal:
grub> root (returned value)
e.g.,
grub> root (hd0,2)
Now, reinstall grub in the MBR i.e. the returned value without number part.
e.g., (hd0)
So, give this command at the terminal:
grub> setup (returned value without number part)
e.g.,
grub> setup (hd0)
Exit the grub-shell prompt using “Ctrl+c”.
Exit the shell prompt using “Ctrl+d”.









Soooper Roshan. Its really awesome. Its now easy to tell people how to do this simple job. All these days we had to explain this petty thing for hours on phone. Now its just a matter of giving one link.
Thanks a lot for this. Great Work!!!
One more thing, I saw you using GNU/Linux. Thats the way to set an example to others. Great!!! Most of them do the mistake of using only Linux part of it which is a blunder according to me. Thanks a lot for giving GNU its due credits. Thanks a lot.
Comment by Madhusudan.C.S — February 29, 2008 @ 3:39 pm |
Roshan. Wherever You Are Right Now…
I Just Wanted You to Know that You Just Saved My Life, Man! Thanks!!!
Comment by Darryl — April 21, 2008 @ 11:55 am |
Super Grub Disk rocks! Multi Linux!!
repair restore recover [reinstall] linux GRUB bootloader/menu,
or multi OS/distro multi disks/partitions MBR!
It works on my ubuntu 7.04 in 1 minute!
see their wiki for
“SGD Quick Menu”
“Multi Distribution Boot Howto”
“Boot Problems”
“Howto Fix Grub”
Comment by meka4996 — June 20, 2008 @ 3:02 am |
Roshan,
Thanks so much! I blew my grub loader tinkering with a program in Mandriva Spring 2008. I was sure I had hours of tedious, frustrating work ahead of me, but as luck would have it, I hit upon your page first.
The reinstallation process worked instantly, exactly as you described it!
drblock
Comment by drblock — July 5, 2008 @ 3:15 pm |
Roshan
Thanks a lot for the informative piece on installation of grub.It should help me big time because twice I wrecked up my Grub and both the times I had to re-install Ubuntu losing all my software installation.
Comment by Siddharth — July 8, 2008 @ 8:31 am |
thanx a lot, God bless you
Comment by fares — August 22, 2008 @ 3:54 pm |
When I tried the find /boot/grub/
Comment by That Anonymous Kid Down The — October 4, 2008 @ 12:39 am |
stage1 thing, it returned two hard drives. One of them was (0,0), which was my Ubuntu hard drive, and the other was (2,0), with openSUSE 11.0. What do I do?
Comment by That Anonymous Kid Down The — October 4, 2008 @ 12:41 am |
new to linux, installed fedora9, got the problem error, after dropping the “$”, I got the drive info, but it also told me “Disk /dev/dm-0 doesn’t contain a valid partition table”. I did just the standard install, only one 80gig drive, anything I’m missing?
thanks in advance.
Comment by bowwhyte — October 21, 2008 @ 4:25 am |
Thanks a million!
Comment by brennan — October 31, 2008 @ 6:51 am |
fantastic! best step by step recovery of a mangled linux install or partition that this noob (migrating from mac os x, not windows, no less) has yet encountered. especially good are the anticipations of common error messages.
Comment by dave — December 6, 2008 @ 8:37 am |
Useful and informative, thanks!
Comment by Shujaa — December 25, 2008 @ 3:21 am |
This is the first how-to I have found, in a whole day trying to fix my grub problem, that said what to do if the “find” command came back as “not found”. Thanks!
Comment by Amanda — January 30, 2009 @ 12:56 am |
I finally clued in. I was trying to install grub to (hd1,1) which is my Ubuntu partition instead of (hd0) which is my windows boot partition. If I selected to boot to my second hard drive I would see the grub menu list but it would not let me start Ubuntu from there but it would let me start windows. Thank you!!!
Comment by smith_mg — February 6, 2009 @ 4:36 am |
You guys are all experts but you really need to understand that for people that are trying to NOT HAVE WINDOWS then Ubuntu support does nothing when the grub loader is lost, no way to recover, no way to reload it, all you guys do is fall back on WINDOWS to fix the mess. To hell with windows and Gates PUT a system boot resotore function on the live CD!!!!!!!!!!!!!!!!! As there are things that somhow destroy the MBR in Liniux and i am tired of having to reinstall a whole OS and live with lost data cause while Unbuntu is GREAT, it is only great if it will BOOT, and this is making me very angry as it has happened a lot. For some reason the Wubi systems do not have this problem but Linux as a stand alone, has a very unstable grub loader and boot system that in time will fail and when it does all of you expert guys fall back on your custom hybrid Vista this or XP that crap with no consideration for people who used the Ubuntu live CD install and either used one of the two choices it gives in the first partition manager on install.
This is what holds you back Ubuntu all your experts have window on the brain, and I do not want a MBR done by gates and I hate haing to go back to dos to Fdisk and start all over and spend a day fixing what a little THOUGHT could have anticipated and stuck a programs on the live CD to RESTORE A BOOT GRUB ON WINDOWLESS SYSTEMS!
Comment by ohn — March 3, 2009 @ 6:10 am |
The guy is right Ubuntu needs to drop the Windows and start making it with people who do not use windows in mind. Once Ubuntu crashes if you don’t have windows then you are screwed and no one at support stops to think about people using a standard install as a stand alone system……. Great system if if starts….. but you never know about the MBR and if the grub is gone.
Comment by Ryah — March 3, 2009 @ 6:13 am |
Thank you very much for this. These instructions worked on CentOS 5.2. That installation wants to either install grub to MBR on hda (where my windows system sits), or to partition record in /boot; I chose the second. After install, Grub would part-way load and then stall with error 15. After doing the grub setup (hd1), everything worked fine. Note, on my system, hdb is initial boot drive in bios.
I was going to reinstall OS after pulling windows drive until I found this helpful place.
Comment by unclesmrgol — March 18, 2009 @ 5:51 pm |
Hi,Roshan…Thank you very much..simply explained you..This will very useful for beginers and all others..
Comment by Abhilash.S>V — March 31, 2009 @ 9:56 am |
I don’t like your blog.
Comment by Nikhil V — April 3, 2009 @ 10:50 am |
This is too much ansuththe
Comment by Nikhil V — April 3, 2009 @ 10:51 am |
and u can use the live disk to boot up your own os too
alls u do is press F6, then escape, then remove the stuff before the “initrd=” stuff
then can put “root=/dev/(root-partition-number) rw” before “initrd=”
and it will boot your system, it gets u into YOUR gui, to which u can do what was suggested up top in a terminal window, and you can have your system back, good as new
thats what i just did.
i do agree it needs the restore option from the DVD editions put in as a option in the live discs.
Comment by sm — April 17, 2009 @ 12:04 am |
delete those two comments man, I didnt write them, why do you still have them around
Comment by n — May 4, 2009 @ 1:43 pm |
Nice work.
Comment by Govanthan M — May 15, 2009 @ 6:23 am |
YAA Adding this to my bookmarks. Thank You
Comment by women high heel shoes — June 14, 2009 @ 2:08 pm |