This is a post I had written in an old blog that I abandoned a long time ago. I re-publish it here to help everyone who might have a problem trying to restore grub.
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:
- Get yourself a small LiveCD, I personally used Slax standard edition 22.214.171.124 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