Have you ever found yourself locked out of a Windows installation and had to reinstall them? If so, you have probably noticed that Windows restores the NTLDR (the NT bootloader) to the MBR and Grub disappears. In order to regain access to your GNU/Linux distribution you have to re-install grub and that can be confusing since nearly 1 out of 2 guides out there WILL NOT work (at least not the way they should)…
This happened to me just yesterday and the (manual) steps I describe below worked fine. Enough with the talking, let’s start.
There are two easy ways to reinstall/restore Grub: either automatically or manually.
The automatic way: Super Grub Disk is a LiveCD-based solution for restoring grub via a user-friendly interface. After a couple of minutes you will be asked to reboot and grub will be restored, simply and easily. This solution worked for many people I know but not for me, so I used the manual way which I describe just below.
The manual way:
This happened to me just yesterday and the (manual) steps I describe below worked fine. Enough with the talking, let’s start.
There are two easy ways to reinstall/restore Grub: either automatically or manually.
The automatic way: Super Grub Disk is a LiveCD-based solution for restoring grub via a user-friendly interface. After a couple of minutes you will be asked to reboot and grub will be restored, simply and easily. This solution worked for many people I know but not for me, so I used the manual way which I describe just below.
The manual way:
- Get yourself a small LiveCD, I personally used Slax standard edition 5.1.8.1 but any LiveCD should do just fine.
- Boot using the LiveCD and mount the partition containing your distribution (if it hasn’t been already mounted by the LiveCD distro)
- Open a terminal window, gain root access, and type: "chroot /mnt/hd??" OR "chroot /media/hd??" where the first "?" stands for the hard disk letter and the second "?" stands for the partition number. Note that some distributions use "/media" for mounting drives, so check both "/mnt" and "/media" before attempting to manually mount the partition. If you don’t know which is the distribution partition (e.g. If you have multiple distros installed) then just navigate to the directories you mounted on the previous step until you determine which is the right one.
- Type "grub", a message saying "Probing devices to guess BIOS drives" should appear, just wait for a couple of minutes and soon you will see the grub prompt (it looks like "grub> _")
- Type "find /boot/grub/stage1". The result will be like "(hd0,5)" or perhaps "(hd0)". Keep this in mind because it is a key-text for the next steps.
- Type "root (hd?,?)", replace the question marks with what the output of the command above was.
- Now we are ready to install grub, select one of the following options depending on the place you want to install grub:
- If you want to install grub on the MBR (recommended for most installations) type "setup (hd?)" where "?" is the result BEFORE the comma that command in step 5 returned
- If you know what you are doing and want to install it on a separate partition, type "setup (hd?,?)" where the first "?" stands for the pre-comma output of the command of step 5 and the second "?" stands for the partition number.
- Type "quit" to exit the grub prompt
- Reboot the computer and remove the LiveCD, grub should now appear
LINKS:
GNU GRUB | Wikipedia Article - GNU GRUB | Wikipedia Article - NTLDR | Wikipedia Article - Master Boot Record (MBR) | Super Grub Disk | Slax |
EDIT: The command in step 6 had accidentally been copied in step 7 too. The guide has been fixed. The right command is "setup (hd?,?)" and not "root (hd?,?)" which should be used only in step 6. Many thanks to the people who pointed that out in their comments.
96 comments:
The procedure posted would do nothing at all! I believe in step 7 the command to use should be "setup (hd?) or setup (hd?,?) to actually do the install.
yes, previous anonymous is exectly right!
without "setup" nothing will happen :(
setup (hd?) for putting grub to MBR is necessary!
anonymous is indeed correct.
You need to follow the root command with:
setup (hd?)
I love how you arrogantly claim most other guides are wrong, but yours is too!
The technique that I use is to boot from a liveCD, chroot to the mounted disk, then use grub-install /dev/hdX or grub-install /dev/hdX#. Hasn't failed yet.
There is another way using one command:
cd /mnt && grub-install --root-directory=. /dev/hda
Subtitude "/mnt" with the folder where the root partition is mounted and and "hda" with the hard disk that contains the MBR sector.
Ram
Thank you all, it seems that during the re-write of the guide (the original version was lost due to a power failure...) I accidentally copied the command of step 6 under step 7 too. The guide has been fixed. :-)
@mike, I had tried many guides to fix GRUB on my own PC but most guides failed to work (even super grub disk failed to restore grub) and so I thought that posting a guide might help somebody out there. This was the reason I mentioned that "nearly 1 out of 2 guides out there WILL NOT work".
Thanks to your contribution the error has been fixed and the guide is now (hopefully :-p) error-free
Good design!
Interesting!
Interesting article, thanks!
Great to see this! Thanks!
Thanks for interesting article.
I like articles like this. Thanks!
very good!
Write something else. Thanks! Best Blog...
Well done. Keep up the great work. Best regards!
I like it a lot! Nice site, I will bookmark!
I like it a lot! Nice site, I will bookmark!
Thanks to author! I like articles like this, very interesting.
Thanks for the nice post!
fQGTZ3 You have a talant! Write more!
Dp6U8L Thanks to author.
9mtKdF The best blog you have!
972N7w Nice Article.
Wonderful blog.
Thanks to author.
Please write anything else!
Hello all!
Please write anything else!
Good job!
Good job!
tpsdJS write more, thanks.
Thanks to author.
Please write anything else!
Wonderful blog.
Hello all!
Hello all!
Wonderful blog.
Please write anything else!
Please write anything else!
Magnific!
Magnific!
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
Hello all!
Friends help you move. Real friends help you move bodies.
A lot of people mistake a short memory for a clear conscience.
Beam me aboard, Scotty..... Sure. Will a 2x10 do?
Save the whales, collect the whole set
Build a watch in 179 easy steps - by C. Forsberg.
Good job!
Oops. My brain just hit a bad sector.
When there's a will, I want to be in it.
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
Calvin, we will not have an anatomically correct snowman!
The gene pool could use a little chlorine.
Nice Article.
Lottery: A tax on people who are bad at math.
When there's a will, I want to be in it.
Friends help you move. Real friends help you move bodies.
Thanks to author.
Build a watch in 179 easy steps - by C. Forsberg.
Good job!
What is a free gift ? Aren't all gifts free?
Ever notice how fast Windows runs? Neither did I.
I don't suffer from insanity. I enjoy every minute of it.
What is a free gift ? Aren't all gifts free?
Oops. My brain just hit a bad sector.
Friends help you move. Real friends help you move bodies.
If ignorance is bliss, you must be orgasmic.
Wonderful blog.
Good job!
I'm not a complete idiot, some parts are missing!
Clap on! , Clap off! clap@#&$NO CARRIER
Change is inevitable, except from a vending machine.
Nice Article.
Lottery: A tax on people who are bad at math.
The gene pool could use a little chlorine.
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
Hello all!
What is a free gift ? Aren't all gifts free?
Build a watch in 179 easy steps - by C. Forsberg.
Build a watch in 179 easy steps - by C. Forsberg.
Give me ambiguity or give me something else.
If ignorance is bliss, you must be orgasmic.
640K ought to be enough for anybody. - Bill Gates 81
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
If ignorance is bliss, you must be orgasmic.
Hello all!
All generalizations are false, including this one.
Clap on! , Clap off! clap@#&$NO CARRIER
Please write anything else!
Give me ambiguity or give me something else.
Ever notice how fast Windows runs? Neither did I.
What is a free gift ? Aren't all gifts free?
Build a watch in 179 easy steps - by C. Forsberg.
When there's a will, I want to be in it.
C++ should have been called B
Post a Comment